Skip to content

Commit 1f8ed2f

Browse files
committed
Initial commit of dap
0 parents  commit 1f8ed2f

21 files changed

+5789
-0
lines changed

.ghci

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
:set -isrc:exe:test
2+
:set -XOverloadedStrings

.gitignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# haskell
2+
stack.yaml.lock
3+
.stack-work/
4+
dist-newstyle/
5+
dist/
6+
cabal.project.local
7+
.ghc.environment.*
8+
*.o
9+
*.hi
10+
11+
# nix
12+
result*
13+
14+
# osx
15+
.DS_Store
16+
17+
# emacs
18+
*~
19+
20+
# tags
21+
TAGS
22+
main
23+
24+
# C
25+
./main
26+
*.dSYM
27+
28+
# stg
29+
*.fullpak
30+
*.modpak
31+
32+
# tags
33+
tags
34+
35+
# external-stg-interpreter
36+
.ext-stg-work

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Revision history for dap
2+
3+
## 0.1.0.0 -- YYYY-mm-dd
4+
5+
* First version. Released on an unsuspecting world.

LICENSE

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2023, haskell-debugger
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
1. Redistributions of source code must retain the above copyright notice, this
9+
list of conditions and the following disclaimer.
10+
11+
2. Redistributions in binary form must reproduce the above copyright notice,
12+
this list of conditions and the following disclaimer in the documentation
13+
and/or other materials provided with the distribution.
14+
15+
3. Neither the name of the copyright holder nor the names of its
16+
contributors may be used to endorse or promote products derived from
17+
this software without specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# dap <img src="https://user-images.githubusercontent.com/875324/235317448-1cf2d543-40a8-4eaa-b765-6576ddd7f84f.png" width="5%" />
2+
3+
A [Debug Adaptor Protocol](https://microsoft.github.io/debug-adapter-protocol) (DAP) library.
4+
5+
This library can be used for constructing debug adaptors for any programming language.
6+
7+
# Table of Contents
8+
1. [Usage](#usage)
9+
2. [Build](#build)
10+
3. [Develop](#develop)
11+
4. [Test](#test)
12+
5. [Docs](#docs)
13+
14+
## Usage
15+
16+
For a real-world implementation see the [haskell-estgi-debugger](https://github.com/haskell-debugger/haskell-estgi-debugger).
17+
18+
```haskell
19+
module Main where
20+
21+
import DAP
22+
23+
-- | Runs server in main thread
24+
--
25+
main :: IO ()
26+
main = runDAPServer config mockServerTalk
27+
where
28+
capabilities = defaultCapabilities
29+
{ supportsConfigurationDoneRequest = True
30+
, supportsHitConditionalBreakpoints = True
31+
, supportsModulesRequest = True
32+
, additionalModuleColumns = [ defaultColumnDescriptor
33+
{ columnDescriptorAttributeName = "Extra"
34+
, columnDescriptorLabel = "Label"
35+
}
36+
]
37+
, supportsValueFormattingOptions = True
38+
, supportTerminateDebuggee = True
39+
, supportsLoadedSourcesRequest = True
40+
}
41+
config = ServerConfig
42+
{ host = testHost
43+
, port = testPort
44+
, serverCapabilities = capabilities
45+
, debugLogging = False
46+
}
47+
48+
-- | Mock server communication, used in test runner
49+
--
50+
mockServerTalk
51+
:: Command
52+
-> Adaptor app ()
53+
mockServerTalk CommandInitialize = do
54+
sendInitializeResponse
55+
sendInitializedEvent
56+
mockServerTalk CommandConfigurationDone = do
57+
sendConfigurationDoneResponse
58+
sendStoppedEvent defaultStoppedEvent
59+
60+
-- | Sample port shared amongst client and server
61+
--
62+
testPort :: Int
63+
testPort = 8001
64+
65+
-- | Sample host shared amongst client and server
66+
--
67+
testHost :: String
68+
testHost = "localhost"
69+
```
70+
71+
## Build
72+
73+
```bash
74+
$ cabal build
75+
```
76+
77+
```bash
78+
$ stack build
79+
```
80+
81+
```bash
82+
$ nix build
83+
```
84+
85+
## Develop
86+
87+
```bash
88+
$ nix-shell --run ghcid
89+
```
90+
91+
## Test
92+
93+
```bash
94+
$ cabal test
95+
```
96+
97+
```bash
98+
$ stack test
99+
```
100+
101+
## Docs
102+
103+
```bash
104+
$ stack haddock
105+
```
106+
107+
```bash
108+
$ cabal haddock
109+
```
110+
111+

cabal.project

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
packages: .

dap.cabal

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: dap
2+
version: 0.1.0.0
3+
description: A library for the Debug Adaptor Protocol (DAP)
4+
synopsis: A debug adaptor protocol library
5+
bug-reports: https://github.com/dap/issues
6+
license: BSD3
7+
license-file: LICENSE
8+
author: David Johnson, Csaba Hruska
9+
maintainer: djohnson.m@gmail.com
10+
copyright: (c) 2023 David Johnson
11+
category: Debuggers, Language
12+
build-type: Simple
13+
tested-with: GHC==9.2.7
14+
cabal-version: >= 1.10
15+
16+
extra-source-files:
17+
CHANGELOG.md
18+
19+
library
20+
exposed-modules:
21+
DAP
22+
other-modules:
23+
DAP.Adaptor
24+
DAP.Event
25+
DAP.Internal
26+
DAP.Response
27+
DAP.Server
28+
DAP.Types
29+
DAP.Utils
30+
build-depends:
31+
aeson >= 2.0.3 && < 2.1,
32+
aeson-pretty >= 0.8.9 && < 0.9,
33+
base < 5,
34+
bytestring >= 0.11.4 && < 0.12,
35+
containers >= 0.6.5 && < 0.7,
36+
lifted-base >= 0.2.3 && < 0.3,
37+
monad-control >= 1.0.3 && < 1.1,
38+
mtl >= 2.2.2 && < 2.3,
39+
network >= 3.1.2 && < 3.2,
40+
network-simple >= 0.4.5 && < 0.5,
41+
text >= 1.2.5 && < 1.3,
42+
time >= 1.11.1 && < 1.12,
43+
unordered-containers >= 0.2.19 && < 0.3,
44+
stm >= 2.5.0 && < 2.6,
45+
transformers-base >= 0.4.6 && < 0.5
46+
hs-source-dirs:
47+
src
48+
default-language:
49+
Haskell2010
50+
51+
test-suite tests
52+
type:
53+
exitcode-stdio-1.0
54+
hs-source-dirs:
55+
test, src
56+
main-is:
57+
Main.hs
58+
other-modules:
59+
DAP.Response
60+
DAP.Internal
61+
DAP.Adaptor
62+
DAP.Server
63+
DAP.Types
64+
DAP.Event
65+
DAP.Utils
66+
build-depends:
67+
aeson
68+
, aeson-pretty
69+
, async < 2.3
70+
, base < 5
71+
, bytestring
72+
, containers
73+
, lifted-base
74+
, monad-control
75+
, hspec < 2.12
76+
, mtl
77+
, network
78+
, network-simple
79+
, stm
80+
, string-conversions < 0.5
81+
, text
82+
, time
83+
, transformers-base
84+
, unordered-containers
85+
default-language:
86+
Haskell2010

default.nix

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{ pkgs ? import <nixpkgs> {} }:
2+
let
3+
dap = pkgs.haskell.packages.ghc927.callCabal2nix "dap" ./. {};
4+
in
5+
{
6+
inherit dap pkgs;
7+
}

nix/default.nix

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
with (builtins.fromJSON (builtins.readFile ./nixpkgs.json));
2+
let
3+
nixpkgs = builtins.fetchTarball {
4+
url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz";
5+
inherit sha256;
6+
};
7+
overlays = [];
8+
config = {};
9+
in
10+
import nixpkgs
11+
{ inherit overlays config;
12+
}

nix/nixpkgs.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"rev" : "2362848adf8",
3+
"sha256" : "0wjr874z2y3hc69slaa7d9cw7rj47r1vmc1ml7dw512jld23pn3p"
4+
}

0 commit comments

Comments
 (0)