Skip to content

Commit 60b85ff

Browse files
committed
Update dap docs and build
1 parent 26f9cac commit 60b85ff

File tree

6 files changed

+118
-129
lines changed

6 files changed

+118
-129
lines changed

dap/README.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,109 @@
33
A [Debug Adaptor Protocol](https://microsoft.github.io/debug-adapter-protocol) (DAP) library.
44

55
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+

dap/cabal.project

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

dap/dap.cabal

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ test-suite tests
5858
other-modules:
5959
DAP.Response
6060
DAP.Internal
61-
DAP.Server
6261
DAP.Adaptor
6362
DAP.Server
6463
DAP.Types

dap/default.nix

Lines changed: 3 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -1,122 +1,7 @@
1-
{ pkgs ? import ./nix
2-
}:
3-
4-
with pkgs.haskell.lib;
5-
1+
{ pkgs ? import <nixpkgs> {} }:
62
let
7-
cabal-src = pkgs.fetchFromGitHub
8-
{ owner = "haskell";
9-
repo = "cabal";
10-
sha256 = "13x3dr257ivalhgiffjnyazffimn4a817dj3p96vvi50nx67cml2";
11-
rev = "3af1731c01c35614fd902ee5c1aec40f5587fde6";
12-
};
13-
ghcidSrc = pkgs.fetchFromGitHub
14-
{ owner = "ndmitchell";
15-
repo = "ghcid";
16-
sha256 = "0bsjbb6n7ssg411k2xj4f881v392hvb7xln99bq1r3vkg14mqqsd";
17-
rev = "e2852979aa644c8fed92d46ab529d2c6c1c62b59";
18-
};
19-
zip-cmd-src = pkgs.fetchFromGitHub
20-
{ owner = "grin-compiler";
21-
repo = "zip-cmd";
22-
sha256 = "1gsdcip4qrd8bbxira7v9yz1b05c0y7jbbd440hwdh5z6y94ah9g";
23-
rev = "97a6a768803958faee855de115c0402f29bad32b";
24-
};
25-
external-stg-src = pkgs.fetchFromGitHub
26-
{ owner = "grin-compiler";
27-
repo = "ghc-whole-program-compiler-project";
28-
sha256 = "0a9qxm29cn0vy5v0d399944j0155ck8pqqk58w1y350g70anych0";
29-
rev = "9d7a96a0b831f980d8c9d5a30a9185b64fbbfa31";
30-
};
31-
souffle-haskell-src = pkgs.fetchFromGitHub
32-
{ owner = "luc-tielen";
33-
repo = "souffle-haskell";
34-
sha256 = "sha256-/BdDkSTlxh3m3ApxqdbDQ1yIGiE6mTfDljfpEYgE5Tg=";
35-
rev = "f8c9fc45eed709110af3d3301393f63f4535c71e";
36-
};
37-
type-errors-pretty-src = pkgs.fetchFromGitHub
38-
{ owner = "kowainik";
39-
repo = "type-errors-pretty";
40-
sha256 = "1yylw5c8ffzybcv7cm6ff0k88an4iz0fhc59md09s9zlns03f3d0";
41-
rev = "c85d6d0a7bf2278ddb03abddb5782a5b6095d343";
42-
};
43-
ghc-wpc-src = builtins.fetchGit
44-
{ url = "https://github.com/grin-compiler/ghc-wpc.git";
45-
ref = "ghc-whole-program-compiler";
46-
submodules = true;
47-
};
48-
ghc-patch = pkgs.fetchpatch {
49-
url = "https://gitlab.haskell.org/ghc/ghc/-/commit/ad2ef3a13f1eb000eab8e3d64592373b91a52806.patch";
50-
sha256 = "sha256-Dm9nOcS20wiA5Op4vF9Y8YqcgSSC3IKRlYusBukzf8Y=";
51-
};
52-
53-
overrides961 = self: super: {
54-
Cabal = self.callCabal2nix "Cabal" "${cabal-src}/Cabal" {};
55-
Cabal-syntax = self.callCabal2nix "Cabal-syntax" "${cabal-src}/Cabal-syntax" {};
56-
Cabal-tests = (self.callCabal2nix "Cabal-tests" "${cabal-src}/Cabal-tests" {});
57-
cabal-install-solver = (self.callCabal2nix "cabal-install-solver" "${cabal-src}/cabal-install-solver" {});
58-
cabal-install = (self.callCabal2nix "cabal-install" "${cabal-src}/cabal-install" {});
59-
Cabal-described = (self.callCabal2nix "Cabal-described" "${cabal-src}/Cabal-described" {});
60-
Cabal-QuickCheck = (self.callCabal2nix "Cabal-QuickCheck" "${cabal-src}/Cabal-QuickCheck" {});
61-
Cabal-tree-diff = (self.callCabal2nix "Cabal-tree-diff" "${cabal-src}/Cabal-tree-diff" {});
62-
zip-cmd = doJailbreak (self.callCabal2nix "zip-cmd" zip-cmd-src {});
63-
zip = dontCheck (doJailbreak (super.zip));
64-
wpc-plugin = self.callCabal2nix "wpc-plugin" "${external-stg-src}/wpc-plugin" {};
65-
external-stg = self.callCabal2nix "external-stg" "${external-stg-src}/external-stg" {};
66-
external-stg-syntax = self.callCabal2nix "external-stg-syntax" "${external-stg-src}/external-stg-syntax" {};
67-
hello = with self;
68-
pkgs.lib.overrideDerivation (addBuildDepends (callCabal2nix "hello" ./hello {}) [zip-cmd external-stg pkgs.gcc]) (drv: {
69-
postInstall = ''
70-
${external-stg}/bin/mkfullpak -a dist/build/hello/hello.o_ghc_stgapp
71-
mv -v dist/build/hello/hello.fullpak $out/bin/hello.fullpak
72-
'';
73-
});
74-
};
75-
76-
overrides924 = self: super: {
77-
type-errors-pretty =
78-
dontCheck (doJailbreak (self.callCabal2nix "type-errors-pretty" type-errors-pretty-src {}));
79-
external-stg =
80-
self.callCabal2nix "external-stg" "${external-stg-src}/external-stg" {};
81-
external-stg-interpreter = with pkgs.haskell.lib;
82-
self.callCabal2nix "external-stg-interpreter" "${external-stg-src}/external-stg-interpreter"
83-
(pkgs.lib.optionalAttrs (pkgs.stdenv.isDarwin) { omp = pkgs.llvmPackages.openmp; });
84-
external-stg-syntax =
85-
self.callCabal2nix "external-stg-syntax" "${external-stg-src}/external-stg-syntax" {};
86-
souffle-haskell = with pkgs;
87-
overrideCabal
88-
(addBuildTool (self.callCabal2nix "souffle-haskell" souffle-haskell-src { }) souffle)
89-
(o: {
90-
doCheck = true;
91-
checkPhase = ''
92-
runHook preCheck
93-
DATALOG_DIR="${o.src}/tests/fixtures/" SOUFFLE_BIN="${souffle}/bin/souffle" ./Setup test
94-
runHook postCheck
95-
'';
96-
});
97-
98-
ghcid =
99-
doJailbreak (self.callCabal2nix "ghcid" ghcidSrc {});
100-
dap =
101-
self.callCabal2nix "dap" ./. {};
102-
};
103-
104-
hPkgs924 = pkgs.haskell.packages.ghc924.override { overrides = overrides924; };
105-
hPkgs961 = pkgs.haskell.packages.ghc961.override { overrides = overrides961; };
106-
3+
dap = pkgs.haskellPackages.callCabal2nix "dap" ./. {};
1074
in
1085
{
109-
inherit pkgs;
110-
inherit (hPkgs961)
111-
hello
112-
zip-cmd
113-
cabal-install
114-
wpc-plugin;
115-
inherit (hPkgs924)
116-
external-stg
117-
external-stg-interpreter
118-
external-stg-syntax
119-
souffle-haskell
120-
ghcid
121-
dap;
6+
inherit dap pkgs;
1227
}

dap/shell.nix

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
let
2-
externalStgDapPkgs = (import ./default.nix {});
3-
in
4-
with externalStgDapPkgs;
1+
with (import ./default.nix {});
52

63
dap.env.overrideAttrs (drv: {
74
shellHook = ''
8-
export PATH=$PATH:${pkgs.haskell.packages.ghc924.stack}/bin
9-
function ghcid () {
10-
${ghcid}/bin/ghcid --poll --allow-eval -c 'cabal repl exe:dap'
11-
}
12-
'';
13-
})
5+
export PATH=$PATH:${pkgs.cabal-install}/bin
6+
'';
7+
})

dap/stack.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
resolver: lts-20.18
2+
3+
packages:
4+
- .

0 commit comments

Comments
 (0)