Skip to content

Latest commit

 

History

History
113 lines (87 loc) · 2.37 KB

README.md

File metadata and controls

113 lines (87 loc) · 2.37 KB

dap

A Debug Adaptor Protocol (DAP) library.

This library can be used for constructing debug adaptors for any programming language.

Table of Contents

  1. Usage
  2. Build
  3. Develop
  4. Test
  5. Docs

Usage

For a real-world implementation see the haskell-estgi-debugger.

module Main where

import DAP

-- | Runs server in main thread
--
main :: IO ()
main = runDAPServer config mockServerTalk
  where
    capabilities = defaultCapabilities
      { supportsConfigurationDoneRequest      = True
      , supportsHitConditionalBreakpoints     = True
      , supportsModulesRequest                = True
      , additionalModuleColumns               = [ defaultColumnDescriptor
                                                  { columnDescriptorAttributeName = "Extra"
                                                  , columnDescriptorLabel = "Label"
                                                  }
                                                ]
      , supportsValueFormattingOptions        = True
      , supportTerminateDebuggee              = True
      , supportsLoadedSourcesRequest          = True
      }
    config = ServerConfig
      { host = testHost
      , port = testPort
      , serverCapabilities = capabilities
      , debugLogging = False
      }

-- | Mock server communication, used in test runner
--
mockServerTalk
  :: Command
  -> Adaptor app ()
mockServerTalk CommandInitialize = do
  sendInitializeResponse
  sendInitializedEvent
mockServerTalk CommandConfigurationDone = do
  sendConfigurationDoneResponse
  sendStoppedEvent defaultStoppedEvent

-- | Sample port shared amongst client and server
--
testPort :: Int
testPort = 8001

-- | Sample host shared amongst client and server
--
testHost :: String
testHost = "localhost"

Build

$ cabal build
$ stack build
$ nix build

Develop

$ nix-shell --run ghcid

Test

$ cabal test
$ stack test

Docs

$ stack haddock
$ cabal haddock