Skip to content

haskell-debugger/dap

Folders and files

NameName
Last commit message
Last commit date
Aug 4, 2023
Aug 4, 2023
Apr 8, 2025
Aug 4, 2023
Aug 4, 2023
Aug 4, 2023
Aug 4, 2023
Aug 4, 2023
Aug 4, 2023
Aug 4, 2023
Dec 13, 2024
Aug 4, 2023
Aug 4, 2023
Aug 4, 2023

Repository files navigation

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