on master help sign in
26 files changed+494−455
since splitsnapshots
unifiedsplit
.github/workflows/ci.yaml+61−21 .gitignore+1 .travis.yml−60 .travis/attach-binary.sh−25 .travis/install-dependencies.sh−22 .travis/install-ghc.sh−16 .travis/install-ghr.sh−21 .travis/install-stack.sh−27 README.markdown+1−2 docker.nix+16−11 docs/introduction_to_the_relational_algebra.markdown+1−1 nix/sources.json+50 nix/sources.nix+171 pkgs.nix−7 project-m36.cabal+30−30 release.nix+16−140 src/bin/ProjectM36/Server/WebSocket/websocket-server.hs+42−9 src/lib/ProjectM36/Server/Config.hs+6 src/lib/ProjectM36/Server/ParseArgs.hs+31−14 src/lib/ProjectM36/Shortcuts.hs+1−1 stack.ghc8.10.yaml+19 stack.ghc8.6.yaml+24−24 stack.ghc8.8.yaml+24−24 test/TutorialD/Interpreter/Import/TutorialD.hs → test/TutorialD/Interpreter/Import/ImportTest.hs test/TutorialD/Interpreter.hs → test/TutorialD/InterpreterTest.hs test/TutorialD/Printer.hs → test/TutorialD/PrinterTest.hs
.github/workflows/ci.yaml+61−21
@@ -6,24 +6,64 @@ jobs:
66 dockerimage:
77 runs-on: ubuntu-latest
88 steps:
9− - uses: actions/checkout@v2.3.1
10− - uses: cachix/install-nix-action@v12
11− with:
12− nix_path: nixpkgs=channel:nixos-unstable
13− - uses: cachix/cachix-action@v8
14− with:
15− name: project-m36
16− signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
17− - run: cachix use iohk
18− - name: docker load
19− run: docker load < $(nix-build docker.nix)
20− - name: docker login
21− run: echo ${{secrets.DOCKERHUB_PASSWORD}} | docker login --username ${{secrets.DOCKERHUB_USER}} --password-stdin
22− - name: docker tag with version
23− run: docker tag project-m36:latest projectm36/project-m36:$(awk '/^Version:/ {print $2}' project-m36.cabal)
24− if: ${{ github.ref == 'refs/heads/master' }}
25− - name: docker tag latest
26− run: docker tag project-m36:latest projectm36/project-m36:latest
27− if: ${{ github.ref == 'refs/heads/master' }}
28− - run: docker push projectm36/project-m36
29− if: ${{ github.ref == 'refs/heads/master' }}
9+ - uses: actions/checkout@v2.3.1
10+ - uses: cachix/install-nix-action@v12
11+ with:
12+ nix_path: nixpkgs=channel:nixos-unstable
13+ - uses: cachix/cachix-action@v8
14+ with:
15+ name: project-m36
16+ signingKey: "${{ secrets.CACHIX_SIGNING_KEY }}"
17+ - run: cachix use iohk
18+ - name: docker load
19+ run: docker load < $(nix-build docker.nix)
20+ - name: docker login
21+ if: ${{ github.ref == 'refs/heads/master' }}
22+ run: echo ${{secrets.DOCKERHUB_PASSWORD}} | docker login --username ${{secrets.DOCKERHUB_USER}} --password-stdin
23+ - name: docker tag with version
24+ run: docker tag project-m36:latest projectm36/project-m36:$(awk '/^Version:/ {print $2}' project-m36.cabal)
25+ if: ${{ github.ref == 'refs/heads/master' }}
26+ - name: docker tag latest
27+ run: docker tag project-m36:latest projectm36/project-m36:latest
28+ if: ${{ github.ref == 'refs/heads/master' }}
29+ - run: docker push projectm36/project-m36
30+ if: ${{ github.ref == 'refs/heads/master' }}
31+
32+ stack-build:
33+ runs-on: ${{ matrix.os }}
34+ strategy:
35+ matrix:
36+ os: [ubuntu-latest]
37+ ghc:
38+ - ghc8.10
39+ - ghc8.8
40+ - ghc8.6
41+ include:
42+ - os: macos-latest
43+ ghc: ghc8.10
44+ env:
45+ STACK_YAML: stack.${{ matrix.ghc }}.yaml
46+ steps:
47+ - uses: actions/checkout@v2
48+ - name: Cache
49+ uses: actions/cache@v1
50+ with:
51+ path: ~/.stack
52+ key: ${{ runner.os }}-build-stack-${{ matrix.ghc }}-${{ hashFiles(env.STACK_YAML) }}-${{ hashFiles('**/*.cabal') }}
53+ restore-keys: |
54+ ${{ runner.os }}-build-stack-${{ matrix.ghc }}-${{ hashFiles(env.STACK_YAML) }}
55+ ${{ runner.os }}-build-stack-${{ matrix.ghc }}
56+ - name: Fix macOS cache bug
57+ run: rm -rf ~/.stack/setup-exe-cache
58+ - name: Build
59+ run: stack build --ghc-options -O2 --local-bin-path out --copy-bins
60+ - name: Test
61+ run: stack test --stack-yaml=${{ env.STACK_YAML }}
62+ - name: HLint
63+ run: curl -sSL https://raw.github.com/ndmitchell/hlint/master/misc/run.sh | sh -s .
64+ - name: Haddock
65+ run: stack --no-install-ghc --system-ghc --no-haddock-deps haddock
66+ - uses: actions/upload-artifact@v2
67+ with:
68+ name: project-m36-${{ matrix.os }}-${{ matrix.ghc }}
69+ path: out/
.gitignore+1
@@ -20,3 +20,4 @@ jupyter/build
2020juyter/dist
2121.ipynb_checkpoints
2222project-m36.nix
23+stack.yaml
.travis.ymldeleted−60
@@ -1,60 +0,0 @@
1−# For more information, see https://github.com/ChrisPenner/haskell-stack-travis-ci
2−language: c
3−sudo: false
4−
5−git:
6− submodules: false # whether to recursively clone submodules
7−
8−cache:
9− directories:
10− - $HOME/.ghc
11− - $HOME/.cabal
12− - $HOME/.stack
13− - .stack-work
14− timeout: 1000
15−
16−matrix:
17− fast_finish: true
18− include:
19− - env: CACHE_NAME=8.8.4 STACK_YAML=stack.ghc8.8.yaml
20− compiler: ": #stack 8.8.4"
21−
22− - env: CACHE_NAME=8.6.5 STACK_YAML=stack.ghc8.6.yaml
23− compiler: ": #stack 8.6.5"
24−
25− - env: CACHE_NAME=osx-8.6.5 STACK_YAML=stack.ghc8.6.yaml
26− os: osx
27− osx_image: xcode11
28− compiler: ": #stack 8.6.5"
29−
30−before_script:
31− - unset CC
32− - export PATH=$HOME/.local/bin:/opt/ghc/$GHC_VERSION/bin:$PATH
33− - ./.travis/install-ghr.sh
34− - ./.travis/install-stack.sh
35−
36−# Here starts the actual work to be performed for the package under test;
37−# any command which exits with a non-zero exit code causes the build to fail.
38−script:
39− - |
40− # Run tests
41− set -e
42− ./.travis/install-dependencies.sh
43− stack --no-terminal --jobs=2 --system-ghc test
44− - |
45− #Run HLint
46− if [[ "$(uname)" = "Linux" ]]; then
47− curl -sL https://raw.github.com/ndmitchell/hlint/master/misc/travis.sh | sh -s lint src test examples --cpp-define VERSION_project_m36=HLINT
48− fi
49− - |
50− #Run Haddock
51− if [[ "$(uname)" = "Linux" ]]; then
52− stack --no-install-ghc --system-ghc --no-haddock-deps haddock
53− fi
54−
55−after_success:
56− - |
57− # Build and ship binary
58− #./.travis/attach-binary.sh
59−
60−# EOF
.travis/attach-binary.shdeleted−25
@@ -1,25 +0,0 @@
1−#!/bin/sh
2−set -o errexit -o verbose
3−
4−if test ! "$BUILD_BINARY" || test ! "$TRAVIS_TAG"
5−then
6− echo 'This is not a release build.'
7−elif test ! "$GITHUB_TOKEN"
8−then
9− echo 'The GITHUB_TOKEN environment variable is not set!'
10− exit 1
11−else
12− echo "Building binary for $TRAVIS_OS_NAME to $TRAVIS_TAG..."
13− stack build --ghc-options -O2 --pedantic
14− echo "Attaching binary for $TRAVIS_OS_NAME to $TRAVIS_TAG..."
15− OWNER="$(echo "$TRAVIS_REPO_SLUG" | cut -f1 -d/)"
16− REPO="$(echo "$TRAVIS_REPO_SLUG" | cut -f2 -d/)"
17− BIN="$(stack path --local-install-root)/bin/$REPO"
18− BUNDLE_NAME="$REPO-$TRAVIS_TAG-$TRAVIS_OS_NAME.tar.gz"
19− cp "$BIN" "./$REPO"
20− chmod +x "./$REPO"
21− tar -czf "$BUNDLE_NAME" "$REPO"
22− echo "SHA256:"
23− shasum -a 256 "$BUNDLE_NAME"
24− ghr -t "$GITHUB_TOKEN" -u "$OWNER" -r "$REPO" --replace "$(git describe --tags)" "$BUNDLE_NAME"
25−fi
.travis/install-dependencies.shdeleted−22
@@ -1,22 +0,0 @@
1−# Run tests
2−if [[ "$(uname)" = "Darwin" ]]; then
3− timeout_cmd="gtimeout"
4−else
5− timeout_cmd="timeout"
6−fi
7−$timeout_cmd 40m stack --no-terminal --jobs=2 --install-ghc --system-ghc build --only-dependencies --fast
8−ret=$?
9−case "$ret" in
10− 0)
11− # continue
12− ;;
13− 124)
14− echo "Timed out while installing dependencies."
15− echo "Try building again by pushing a new commit."
16− exit 1
17− ;;
18− *)
19− echo "Failed to install dependencies; stack exited with $ret"
20− exit "$ret"
21− ;;
22−esac
.travis/install-ghc.shdeleted−16
@@ -1,16 +0,0 @@
1−#!/bin/sh
2−set -eux
3−#assume stack is installed
4−STACK=~/.local/bin/stack
5−
6−fetch_ghc_osx() {
7− echo "Using stack to install GHC $GHC_VERSION"
8− $STACK setup $GHC_VERSION
9−}
10−
11−if [ "$(uname)" = "Darwin" ]; then
12− fetch_ghc_osx
13−else
14− #installed by apt
15− echo "Linux GHC $GHC_VERSION via APT already installed."
16−fi
.travis/install-ghr.shdeleted−21
@@ -1,21 +0,0 @@
1−#!/bin/sh
2−set -o errexit -o verbose
3−
4−if test ! "$BUILD_BINARY" || test ! "$TRAVIS_TAG"
5−then
6− echo 'This is not a release build.'
7−else
8− if [ "$TRAVIS_OS_NAME" = "linux" ]
9− then
10− ARCH="linux"
11− else
12− ARCH="darwin"
13− fi
14− echo "Installing ghr"
15− URL="https://github.com/tcnksm/ghr/releases/download/v0.5.4/ghr_v0.5.4_${ARCH}_386.zip"
16− curl -L ${URL} > ghr.zip
17− mkdir -p "$HOME/bin"
18− export PATH="$HOME/bin:$PATH"
19− unzip ghr.zip -d "$HOME/bin"
20− rm ghr.zip
21−fi
.travis/install-stack.shdeleted−27
@@ -1,27 +0,0 @@
1−#!/bin/sh
2−
3−# Adapted from https://github.com/commercialhaskell/stack
4−
5−set -eux
6−
7−travis_retry() {
8− cmd=$*
9− $cmd || (sleep 2 && $cmd) || (sleep 10 && $cmd)
10−}
11−
12−fetch_stack_osx() {
13− curl -skL https://get.haskellstack.org/stable/osx-x86_64.tar.gz | tar xz --strip-components=1 --include '*/stack' -C ~/.local/bin;
14−}
15−
16−fetch_stack_linux() {
17− curl -sL https://get.haskellstack.org/stable/linux-x86_64.tar.gz | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack';
18−}
19−
20−# We need stack to generate cabal files with precise bounds, even for cabal
21−# builds.
22−mkdir -p ~/.local/bin;
23−if [ "$(uname)" = "Darwin" ]; then
24− travis_retry fetch_stack_osx
25−else
26− travis_retry fetch_stack_linux
27−fi
README.markdown+1−2
@@ -4,7 +4,6 @@
44[![Public Domain](https://img.shields.io/badge/license-Public%20Domain-brightgreen.svg)](http://unlicense.org)
55[![Hackage](https://img.shields.io/hackage/v/project-m36.svg)](http://hackage.haskell.org/package/project-m36)
66[![Hackage dependency status](https://img.shields.io/hackage-deps/v/project-m36.svg)](http://packdeps.haskellers.com/feed?needle=project-m36)
7−[![Build status](https://travis-ci.org/agentm/project-m36.svg?branch=master)](https://travis-ci.org/agentm/project-m36)
87[![Windows Build status](https://ci.appveyor.com/api/projects/status/q7jyddd6dy1ibqdo/branch/master?svg=true)](https://ci.appveyor.com/project/agentm/project-m36)
98[![Github Workflow status](https://github.com/agentm/project-m36/workflows/CI/badge.svg)](https://github.com/agentm/project-m36/actions?query=workflow%3ACI)
109
@@ -45,7 +44,7 @@ Project:M36 supports multiple frontends which target different audiences.
4544
4645* [Developer's Blog](https://agentm.github.io/project-m36/)
4746* [Mailing List/Discussion Group](https://groups.google.com/d/forum/project-m36)
48−* IRC Channel: chat.freenode.net #project-m36
47+* IRC Channel: irc.libera.chat #project-m36 -- [Chat via Web Client](http://kiwiirc.com/nextclient/irc.libera.chat:+6697/#project-m36)
4948* [Hackage](https://hackage.haskell.org/package/project-m36)
5049* [Diogo Biazus' Project:M36 Video Tutorial](https://www.youtube.com/watch?v=_GC_lxlVEnE)
5150
docker.nix+16−11
@@ -1,13 +1,18 @@
1−{ pkgs ? import ./pkgs.nix }:
1+{ compiler ? "ghc8104"
2+, sources ? import ./nix/sources.nix
3+, pkgs ? import sources.nixpkgs { }
4+}:
25let
3− release = import ./release.nix { inherit pkgs; };
4− static-project-m36 = pkgs.haskell.lib.justStaticExecutables release.project;
6+ release = import ./release.nix { inherit pkgs compiler sources; };
7+ static-project-m36 = pkgs.haskell.lib.dontCheck (pkgs.haskell.lib.justStaticExecutables release.project);
58in
6− pkgs.dockerTools.buildImage {
7− name = "project-m36";
8− tag = "latest";
9− contents = [static-project-m36];
10− #expose default project-m36 and websocket server ports
11− config = { Env = ["LC_ALL=en_US.UTF-8"];
12− ExposedPorts = { "6543/tcp" = {}; "8000/tcp" = {}; }; };
13− }
9+pkgs.dockerTools.buildImage {
10+ name = "project-m36";
11+ tag = "latest";
12+ contents = [ static-project-m36 ];
13+ # expose default project-m36 and websocket server ports
14+ config = {
15+ Env = [ "LC_ALL=en_US.UTF-8" ];
16+ ExposedPorts = { "6543/tcp" = { }; "8000/tcp" = { }; };
17+ };
18+}
docs/introduction_to_the_relational_algebra.markdown+1−1
@@ -202,7 +202,7 @@ Join (Instructor relation)
202202
203203(Course Relation)
204204
205−|(Course Name, Course Name Type)|(Instructor, Instructor Name Type)|(Course Room Number, Room Number Type)|
205+|(Course Name, Course Name Type)|(Instructor Name, Instructor Name Type)|(Course Room Number, Room Number Type)|
206206|-------------------------------|----------------------------------|--------------------------------------|
207207|English 1|Steve|Room 104|
208208|French 2|Bob|Room 103|
nix/sources.jsonnew file+50
@@ -0,0 +1,50 @@
1+{
2+ "curryer": {
3+ "branch": "master",
4+ "description": "Fast Haskell RPC",
5+ "homepage": null,
6+ "owner": "agentm",
7+ "repo": "curryer",
8+ "rev": "74ecaac619ad1165a4517d5c0f4e530493bda130",
9+ "sha256": "1izdvzj00k0y76ixm7dfgvq2fzphb8h4nzqgwkl3p0bg0806rsn1",
10+ "type": "tarball",
11+ "url": "https://github.com/agentm/curryer/archive/74ecaac619ad1165a4517d5c0f4e530493bda130.tar.gz",
12+ "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
13+ },
14+ "niv": {
15+ "branch": "master",
16+ "description": "Easy dependency management for Nix projects",
17+ "homepage": "https://github.com/nmattia/niv",
18+ "owner": "nmattia",
19+ "repo": "niv",
20+ "rev": "1819632b5823e0527da28ad82fecd6be5136c1e9",
21+ "sha256": "08jz17756qchq0zrqmapcm33nr4ms9f630mycc06i6zkfwl5yh5i",
22+ "type": "tarball",
23+ "url": "https://github.com/nmattia/niv/archive/1819632b5823e0527da28ad82fecd6be5136c1e9.tar.gz",
24+ "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
25+ },
26+ "nixpkgs": {
27+ "branch": "master",
28+ "description": "Nix Packages collection",
29+ "homepage": "",
30+ "owner": "NixOS",
31+ "repo": "nixpkgs",
32+ "rev": "429c23aad0fce9ef38b0e60d55d7459c19d53ddc",
33+ "sha256": "1nj8sh1fnxp07jdlvjkijwfd1pnsi2zj0ivy7a0dhx02g63byhg3",
34+ "type": "tarball",
35+ "url": "https://github.com/NixOS/nixpkgs/archive/429c23aad0fce9ef38b0e60d55d7459c19d53ddc.tar.gz",
36+ "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
37+ },
38+ "streamly": {
39+ "branch": "ac3af8749194f1788704dda8667d0b3807075cc2",
40+ "description": "Beautiful Streaming, Concurrent and Reactive Composition (Haskell)",
41+ "homepage": "https://hackage.haskell.org/package/streamly",
42+ "owner": "composewell",
43+ "repo": "streamly",
44+ "rev": "ac3af8749194f1788704dda8667d0b3807075cc2",
45+ "sha256": "04d8fk654vawdfs0dfidmq2awwgwi8x44iv8r7vqz70zkcsd5fij",
46+ "type": "tarball",
47+ "url": "https://github.com/composewell/streamly/archive/ac3af8749194f1788704dda8667d0b3807075cc2.tar.gz",
48+ "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
49+ }
50+}
nix/sources.nixnew file+171
@@ -0,0 +1,171 @@
1+# This file has been generated by Niv.
2+
3+let
4+
5+ #
6+ # The fetchers. fetch_<type> fetches specs of type <type>.
7+ #
8+
9+ fetch_file = pkgs: name: spec:
10+ let
11+ name' = sanitizeName name + "-src";
12+ in
13+ if spec.builtin or true then
14+ builtins_fetchurl { inherit (spec) url sha256; name = name'; }
15+ else
16+ pkgs.fetchurl { inherit (spec) url sha256; name = name'; };
17+
18+ fetch_tarball = pkgs: name: spec:
19+ let
20+ name' = sanitizeName name + "-src";
21+ in
22+ if spec.builtin or true then
23+ builtins_fetchTarball { name = name'; inherit (spec) url sha256; }
24+ else
25+ pkgs.fetchzip { name = name'; inherit (spec) url sha256; };
26+
27+ fetch_git = name: spec:
28+ let
29+ ref =
30+ if spec ? ref then spec.ref else
31+ if spec ? branch then "refs/heads/${spec.branch}" else
32+ if spec ? tag then "refs/tags/${spec.tag}" else
33+ abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!";
34+ in
35+ builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; };
36+
37+ fetch_local = spec: spec.path;
38+
39+ fetch_builtin-tarball = name: throw
40+ ''[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`.
41+ $ niv modify ${name} -a type=tarball -a builtin=true'';
42+
43+ fetch_builtin-url = name: throw
44+ ''[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`.
45+ $ niv modify ${name} -a type=file -a builtin=true'';
46+
47+ #
48+ # Various helpers
49+ #
50+
51+ # https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695
52+ sanitizeName = name:
53+ (
54+ concatMapStrings (s: if builtins.isList s then "-" else s)
55+ (
56+ builtins.split "[^[:alnum:]+._?=-]+"
57+ ((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name)
58+ )
59+ );
60+
61+ # The set of packages used when specs are fetched using non-builtins.
62+ mkPkgs = sources: system:
63+ let
64+ sourcesNixpkgs =
65+ import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; };
66+ hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
67+ hasThisAsNixpkgsPath = <nixpkgs> == ./.;
68+ in
69+ if builtins.hasAttr "nixpkgs" sources
70+ then sourcesNixpkgs
71+ else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then
72+ import <nixpkgs> {}
73+ else
74+ abort
75+ ''
76+ Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
77+ add a package called "nixpkgs" to your sources.json.
78+ '';
79+
80+ # The actual fetching function.
81+ fetch = pkgs: name: spec:
82+
83+ if ! builtins.hasAttr "type" spec then
84+ abort "ERROR: niv spec ${name} does not have a 'type' attribute"
85+ else if spec.type == "file" then fetch_file pkgs name spec
86+ else if spec.type == "tarball" then fetch_tarball pkgs name spec
87+ else if spec.type == "git" then fetch_git name spec
88+ else if spec.type == "local" then fetch_local spec
89+ else if spec.type == "builtin-tarball" then fetch_builtin-tarball name
90+ else if spec.type == "builtin-url" then fetch_builtin-url name
91+ else
92+ abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}";
93+
94+ # If the environment variable NIV_OVERRIDE_${name} is set, then use
95+ # the path directly as opposed to the fetched source.
96+ replace = name: drv:
97+ let
98+ saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name;
99+ ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}";
100+ in
101+ if ersatz == "" then drv else ersatz;
102+
103+ # Ports of functions for older nix versions
104+
105+ # a Nix version of mapAttrs if the built-in doesn't exist
106+ mapAttrs = builtins.mapAttrs or (
107+ f: set: with builtins;
108+ listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set))
109+ );
110+
111+ # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295
112+ range = first: last: if first > last then [] else builtins.genList (n: first + n) (last - first + 1);
113+
114+ # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257
115+ stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1));
116+
117+ # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269
118+ stringAsChars = f: s: concatStrings (map f (stringToCharacters s));
119+ concatMapStrings = f: list: concatStrings (map f list);
120+ concatStrings = builtins.concatStringsSep "";
121+
122+ # https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331
123+ optionalAttrs = cond: as: if cond then as else {};
124+
125+ # fetchTarball version that is compatible between all the versions of Nix
126+ builtins_fetchTarball = { url, name ? null, sha256 }@attrs:
127+ let
128+ inherit (builtins) lessThan nixVersion fetchTarball;
129+ in
130+ if lessThan nixVersion "1.12" then
131+ fetchTarball ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
132+ else
133+ fetchTarball attrs;
134+
135+ # fetchurl version that is compatible between all the versions of Nix
136+ builtins_fetchurl = { url, name ? null, sha256 }@attrs:
137+ let
138+ inherit (builtins) lessThan nixVersion fetchurl;
139+ in
140+ if lessThan nixVersion "1.12" then
141+ fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
142+ else
143+ fetchurl attrs;
144+
145+ # Create the final "sources" from the config
146+ mkSources = config:
147+ mapAttrs (
148+ name: spec:
149+ if builtins.hasAttr "outPath" spec
150+ then abort
151+ "The values in sources.json should not have an 'outPath' attribute"
152+ else
153+ spec // { outPath = replace name (fetch config.pkgs name spec); }
154+ ) config.sources;
155+
156+ # The "config" used by the fetchers
157+ mkConfig =
158+ { sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null
159+ , sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile)
160+ , system ? builtins.currentSystem
161+ , pkgs ? mkPkgs sources system
162+ }: rec {
163+ # The sources, i.e. the attribute set of spec name to spec
164+ inherit sources;
165+
166+ # The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers
167+ inherit pkgs;
168+ };
169+
170+in
171+mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); }
pkgs.nixdeleted−7
@@ -1,7 +0,0 @@
1−let
2−nixpkgs = builtins.fetchTarball {
3− url = "https://github.com/NixOS/nixpkgs/archive/refs/tags/20.09.tar.gz";
4− sha256 = "1wg61h4gndm3vcprdcg7rc4s1v3jkm5xd7lw8r2f67w502y94gcy";
5−};
6−in
7−import nixpkgs { config.allowBroken = true; }
project-m36.cabal+30−30
@@ -2,7 +2,7 @@ Cabal-Version: 2.2
22Name: project-m36
33Version: 0.9.3
44License: MIT
5−--note that this license specification is erroneous and only labeled MIT to appease hackage which does not recognize public domain packages in cabal >2.2- Project:M36 is dedicated to the public domain
5+--note that this license specification is erroneous and only labeled MIT to appease hackage which does not recognize public domain packages in cabal >2.2- Project:M36 is dedicated to the public domain
66Build-Type: Simple
77Homepage: https://github.com/agentm/project-m36
88Bug-Reports: https://github.com/agentm/project-m36/issues
@@ -143,7 +143,7 @@ Library
143143 Hs-Source-Dirs: ./src/lib
144144 Default-Language: Haskell2010
145145 Default-Extensions: OverloadedStrings, CPP
146− if !flag(stack)
146+ if !flag(stack)
147147 Build-Depends: deferred-folds
148148
149149Executable tutd
@@ -187,8 +187,8 @@ Executable tutd
187187 curryer-rpc,
188188 prettyprinter,
189189 cryptohash-sha256,
190− --due to decode signature change
191− base16-bytestring >= 1.0.0.0,
190+ --due to decode signature change
191+ base16-bytestring >= 1.0.0.0,
192192 http-conduit,
193193 modern-uri,
194194 http-types
@@ -270,11 +270,11 @@ Executable bigrel
270270 GHC-Prof-Options: -fprof-auto -rtsopts -threaded -Wall
271271
272272Common commontest
273− Default-Language: Haskell2010
273+ Default-Language: Haskell2010
274274 Build-Depends: base, HUnit, Cabal, containers, hashable, unordered-containers, mtl, vector, time, hashable-time, bytestring, uuid, stm, deepseq, deepseq-generics,parallel, cassava, attoparsec, gnuplot, directory, temporary, haskeline, megaparsec, text, base64-bytestring, data-interval, filepath, transformers, stm-containers, list-t, websockets, optparse-applicative, network, aeson, project-m36, random, MonadRandom, semigroups, parser-combinators, winery, curryer-rpc, prettyprinter, base64-bytestring, modern-uri, http-types, http-conduit, base16-bytestring,cryptohash-sha256
275275 Default-Extensions: OverloadedStrings
276276 GHC-Options: -Wall -threaded
277− Hs-Source-Dirs: ./src/bin, ., test/
277+ Hs-Source-Dirs: test, src/bin
278278
279279Benchmark basic-benchmark
280280 Default-Language: Haskell2010
@@ -287,7 +287,7 @@ Benchmark basic-benchmark
287287 if flag(profiler)
288288 GHC-Prof-Options: -fprof-auto -rtsopts -threaded -Wall
289289
290−--benchmark inserts, updates, deletes for a basic use-case to shake out any space leaks
290+--benchmark inserts, updates, deletes for a basic use-case to shake out any space leaks
291291Benchmark update-exprs
292292 Default-Language: Haskell2010
293293 Default-Extensions: OverloadedStrings
@@ -302,7 +302,7 @@ Benchmark update-exprs
302302Test-Suite test-tutoriald
303303 import: commontest
304304 type: exitcode-stdio-1.0
305− main-is: test/TutorialD/Interpreter.hs
305+ main-is: TutorialD/InterpreterTest.hs
306306 Other-Modules: TutorialD.Interpreter, TutorialD.Interpreter.Base, TutorialD.Interpreter.Export.Base, TutorialD.Interpreter.Export.CSV, TutorialD.Interpreter.Import.Base, TutorialD.Interpreter.Import.CSV, TutorialD.Interpreter.Import.TutorialD, TutorialD.Interpreter.RODatabaseContextOperator, TutorialD.Interpreter.RelationalExpr, TutorialD.Interpreter.TransactionGraphOperator, TutorialD.Interpreter.Types, TutorialD.Interpreter.DatabaseContextExpr, TutorialD.Interpreter.InformationOperator, TutorialD.Interpreter.Import.BasicExamples, TutorialD.Interpreter.DatabaseContextIOOperator, TutorialD.Interpreter.TestBase, TutorialD.Interpreter.TransGraphRelationalOperator, TutorialD.Interpreter.SchemaOperator, TutorialD.Printer
307307 Build-Depends: base, HUnit, Cabal, containers, hashable, unordered-containers, mtl, vector, time, hashable-time, bytestring, uuid, stm, deepseq, deepseq-generics, parallel, cassava, attoparsec, gnuplot, directory, temporary, haskeline, megaparsec, text, base64-bytestring, data-interval, filepath, stm-containers, list-t, project-m36, random, MonadRandom, semigroups, parser-combinators, prettyprinter
308308
@@ -310,56 +310,56 @@ Test-Suite test-tutoriald-atomfunctionscript
310310 import: commontest
311311 type: exitcode-stdio-1.0
312312 Other-Modules: TutorialD.Interpreter, TutorialD.Interpreter.Base, TutorialD.Interpreter.DatabaseContextExpr, TutorialD.Interpreter.DatabaseContextIOOperator, TutorialD.Interpreter.Export.Base, TutorialD.Interpreter.Export.CSV, TutorialD.Interpreter.Import.Base, TutorialD.Interpreter.Import.BasicExamples, TutorialD.Interpreter.Import.CSV, TutorialD.Interpreter.Import.TutorialD, TutorialD.Interpreter.InformationOperator, TutorialD.Interpreter.RODatabaseContextOperator, TutorialD.Interpreter.RelationalExpr, TutorialD.Interpreter.TestBase, TutorialD.Interpreter.TransGraphRelationalOperator, TutorialD.Interpreter.TransactionGraphOperator, TutorialD.Interpreter.Types, TutorialD.Interpreter.SchemaOperator, TutorialD.Printer
313− main-is: test/TutorialD/Interpreter/AtomFunctionScript.hs
313+ main-is: TutorialD/Interpreter/AtomFunctionScript.hs
314314
315315Test-Suite test-tutoriald-databasecontextfunctionscript
316316 import: commontest
317317 type: exitcode-stdio-1.0
318318 Other-Modules: TutorialD.Interpreter, TutorialD.Interpreter.Base, TutorialD.Interpreter.DatabaseContextExpr, TutorialD.Interpreter.DatabaseContextIOOperator, TutorialD.Interpreter.Export.Base, TutorialD.Interpreter.Export.CSV, TutorialD.Interpreter.Import.Base, TutorialD.Interpreter.Import.BasicExamples, TutorialD.Interpreter.Import.CSV, TutorialD.Interpreter.Import.TutorialD, TutorialD.Interpreter.InformationOperator, TutorialD.Interpreter.RODatabaseContextOperator, TutorialD.Interpreter.RelationalExpr, TutorialD.Interpreter.TestBase, TutorialD.Interpreter.TransGraphRelationalOperator, TutorialD.Interpreter.TransactionGraphOperator, TutorialD.Interpreter.Types, TutorialD.Interpreter.SchemaOperator, TutorialD.Printer
319− main-is: test/TutorialD/Interpreter/DatabaseContextFunctionScript.hs
319+ main-is: TutorialD/Interpreter/DatabaseContextFunctionScript.hs
320320
321321Test-Suite test-relation
322322 import: commontest
323323 type: exitcode-stdio-1.0
324− main-is: test/Relation/Basic.hs
324+ main-is: Relation/Basic.hs
325325
326326Test-Suite test-static-optimizer
327327 import: commontest
328328 type: exitcode-stdio-1.0
329− main-is: test/Relation/StaticOptimizer.hs
329+ main-is: Relation/StaticOptimizer.hs
330330
331331Test-Suite test-transactiongraph-persist
332332 import: commontest
333333 type: exitcode-stdio-1.0
334− main-is: test/TransactionGraph/Persist.hs
334+ main-is: TransactionGraph/Persist.hs
335335 Other-Modules: TutorialD.Interpreter.Base, TutorialD.Interpreter.RelationalExpr, TutorialD.Interpreter.Types, TutorialD.Interpreter.DatabaseContextExpr, TutorialD.Interpreter.Import.BasicExamples, TutorialD.Printer
336336
337337Test-Suite test-relation-import-csv
338338 import: commontest
339339 type: exitcode-stdio-1.0
340− main-is: test/Relation/Import/CSV.hs
340+ main-is: Relation/Import/CSV.hs
341341
342342Test-Suite test-tutoriald-import-tutoriald
343343 import: commontest
344344 type: exitcode-stdio-1.0
345− main-is: test/TutorialD/Interpreter/Import/TutorialD.hs
345+ main-is: TutorialD/Interpreter/Import/ImportTest.hs
346346 Other-Modules: TutorialD.Interpreter.Base, TutorialD.Interpreter.Import.Base, TutorialD.Interpreter.Import.TutorialD, TutorialD.Interpreter.RelationalExpr, TutorialD.Interpreter.Types, TutorialD.Interpreter.DatabaseContextExpr, TutorialD.Interpreter.Import.BasicExamples, TutorialD.Printer
347347
348348Test-Suite test-relation-export-csv
349349 import: commontest
350350 type: exitcode-stdio-1.0
351− main-is: test/Relation/Export/CSV.hs
351+ main-is: Relation/Export/CSV.hs
352352
353353Test-Suite test-transactiongraph-merge
354354 import: commontest
355355 type: exitcode-stdio-1.0
356− main-is: test/TransactionGraph/Merge.hs
356+ main-is: TransactionGraph/Merge.hs
357357
358358
359359Test-Suite test-prettyprinter
360360 import: commontest
361361 type: exitcode-stdio-1.0
362− main-is: test/TutorialD/Printer.hs
362+ main-is: TutorialD/PrinterTest.hs
363363 Other-Modules: TutorialD.Printer, TutorialD.Interpreter.Base, TutorialD.Interpreter.RelationalExpr, TutorialD.Interpreter.Types
364364
365365benchmark bench
@@ -370,7 +370,7 @@ benchmark bench
370370Test-Suite test-server
371371 import: commontest
372372 type: exitcode-stdio-1.0
373− main-is: test/Server/Main.hs
373+ main-is: Server/Main.hs
374374
375375
376376Executable Example-SimpleClient
@@ -428,12 +428,12 @@ Executable Example-DerivingCustomTupleable
428428Test-Suite test-scripts
429429 import: commontest
430430 type: exitcode-stdio-1.0
431− main-is: test/scripts.hs
431+ main-is: scripts.hs
432432 Other-Modules: TutorialD.Interpreter.Base, TutorialD.Interpreter.DatabaseContextExpr, TutorialD.Interpreter.Import.Base, TutorialD.Interpreter.Import.TutorialD, TutorialD.Interpreter.RelationalExpr, TutorialD.Interpreter.Types, TutorialD.Interpreter.Import.BasicExamples, TutorialD.Printer
433433
434434Executable project-m36-websocket-server
435435 Default-Language: Haskell2010
436− Build-Depends: base, aeson, path-pieces, either, conduit, http-api-data, template-haskell, websockets, aeson, optparse-applicative, project-m36, containers, bytestring, text, vector, uuid, megaparsec, haskeline, mtl, directory, base64-bytestring, random, MonadRandom, time, semigroups, attoparsec, parser-combinators, prettyprinter, network, modern-uri, http-conduit, base16-bytestring, http-types, cryptohash-sha256
436+ Build-Depends: base, aeson, path-pieces, either, conduit, http-api-data, template-haskell, websockets, aeson, optparse-applicative, project-m36, containers, bytestring, text, vector, uuid, megaparsec, haskeline, mtl, directory, base64-bytestring, random, MonadRandom, time, semigroups, attoparsec, parser-combinators, prettyprinter, network, modern-uri, http-conduit, base16-bytestring, http-types, cryptohash-sha256, wai, wai-websockets, warp, warp-tls
437437 Main-Is: ProjectM36/Server/WebSocket/websocket-server.hs
438438 Other-Modules: ProjectM36.Client.Json, ProjectM36.Server.RemoteCallTypes.Json, ProjectM36.Server.WebSocket, TutorialD.Interpreter, TutorialD.Interpreter.Base, TutorialD.Interpreter.DatabaseContextExpr, TutorialD.Interpreter.DatabaseContextIOOperator, TutorialD.Interpreter.Export.Base, TutorialD.Interpreter.Export.CSV, TutorialD.Interpreter.Import.Base, TutorialD.Interpreter.Import.BasicExamples, TutorialD.Interpreter.Import.CSV, TutorialD.Interpreter.Import.TutorialD, TutorialD.Interpreter.InformationOperator, TutorialD.Interpreter.RODatabaseContextOperator, TutorialD.Interpreter.RelationalExpr, TutorialD.Interpreter.TransactionGraphOperator, TutorialD.Interpreter.Types, TutorialD.Interpreter.TransGraphRelationalOperator, TutorialD.Interpreter.SchemaOperator, TutorialD.Printer
439439 GHC-Options: -Wall -threaded
@@ -443,39 +443,39 @@ Executable project-m36-websocket-server
443443Test-Suite test-websocket-server
444444 import: commontest
445445 type: exitcode-stdio-1.0
446− main-is: test/Server/WebSocket.hs
446+ main-is: Server/WebSocket.hs
447447 Other-Modules: TutorialD.Interpreter.Export.Base, TutorialD.Interpreter.Export.CSV, TutorialD.Interpreter.Import.BasicExamples, TutorialD.Interpreter.Import.CSV, TutorialD.Interpreter.InformationOperator, TutorialD.Interpreter.RODatabaseContextOperator, TutorialD.Interpreter.TransactionGraphOperator, ProjectM36.Client.Json, ProjectM36.Server.RemoteCallTypes.Json, ProjectM36.Server.WebSocket, TutorialD.Interpreter, TutorialD.Interpreter.Base, TutorialD.Interpreter.DatabaseContextExpr, TutorialD.Interpreter.Import.Base, TutorialD.Interpreter.Import.TutorialD, TutorialD.Interpreter.RelationalExpr, TutorialD.Interpreter.Types, TutorialD.Interpreter.DatabaseContextIOOperator, TutorialD.Interpreter.TransGraphRelationalOperator, TutorialD.Interpreter.SchemaOperator, TutorialD.Printer
448448
449449Test-Suite test-isomorphic-schemas
450450 import: commontest
451451 type: exitcode-stdio-1.0
452− main-is: test/IsomorphicSchema.hs
452+ main-is: IsomorphicSchema.hs
453453
454454Test-Suite test-atomable
455455 import: commontest
456456 type: exitcode-stdio-1.0
457− main-is: test/Relation/Atomable.hs
457+ main-is: Relation/Atomable.hs
458458 Other-Modules: TutorialD.Interpreter, TutorialD.Interpreter.Base, TutorialD.Interpreter.DatabaseContextExpr, TutorialD.Interpreter.DatabaseContextIOOperator, TutorialD.Interpreter.Export.Base, TutorialD.Interpreter.Export.CSV, TutorialD.Interpreter.Import.Base, TutorialD.Interpreter.Import.BasicExamples, TutorialD.Interpreter.Import.CSV, TutorialD.Interpreter.Import.TutorialD, TutorialD.Interpreter.InformationOperator, TutorialD.Interpreter.RODatabaseContextOperator, TutorialD.Interpreter.RelationalExpr, TutorialD.Interpreter.SchemaOperator, TutorialD.Interpreter.TestBase, TutorialD.Interpreter.TransGraphRelationalOperator, TutorialD.Interpreter.TransactionGraphOperator, TutorialD.Interpreter.Types, TutorialD.Printer
459459
460460Test-Suite test-multiprocess-access
461461 import: commontest
462462 type: exitcode-stdio-1.0
463− main-is: test/MultiProcessDatabaseAccess.hs
463+ main-is: MultiProcessDatabaseAccess.hs
464464
465465Test-Suite test-transactiongraph-automerge
466466 import: commontest
467467 type: exitcode-stdio-1.0
468− main-is: test/TransactionGraph/Automerge.hs
468+ main-is: TransactionGraph/Automerge.hs
469469 Other-Modules: TutorialD.Interpreter, TutorialD.Interpreter.Base, TutorialD.Interpreter.DatabaseContextExpr, TutorialD.Interpreter.DatabaseContextIOOperator, TutorialD.Interpreter.Export.Base, TutorialD.Interpreter.Export.CSV, TutorialD.Interpreter.Import.Base, TutorialD.Interpreter.Import.BasicExamples, TutorialD.Interpreter.Import.CSV, TutorialD.Interpreter.Import.TutorialD, TutorialD.Interpreter.InformationOperator, TutorialD.Interpreter.RODatabaseContextOperator, TutorialD.Interpreter.RelationalExpr, TutorialD.Interpreter.SchemaOperator, TutorialD.Interpreter.TestBase, TutorialD.Interpreter.TransGraphRelationalOperator, TutorialD.Interpreter.TransactionGraphOperator, TutorialD.Interpreter.Types, TutorialD.Printer
470470
471471Test-Suite test-tupleable
472472 import: commontest
473473 type: exitcode-stdio-1.0
474− main-is: test/Relation/Tupleable.hs
474+ main-is: Relation/Tupleable.hs
475475
476476Test-Suite test-client-simple
477477 import: commontest
478− Main-Is: test/Client/Simple.hs
478+ Main-Is: Client/Simple.hs
479479 type: exitcode-stdio-1.0
480480
481481-- test for file handle leaks
@@ -506,9 +506,9 @@ Executable handles
506506 HS-Source-Dirs: ./src/bin
507507 if flag(profiler)
508508 GHC-Prof-Options: -fprof-auto -rtsopts -threaded -Wall
509−
509+
510510Test-Suite test-dataframe
511511 import: commontest
512512 type: exitcode-stdio-1.0
513− Main-Is: test/DataFrame.hs
513+ Main-Is: DataFrame.hs
514514 Other-Modules: TutorialD.Interpreter, TutorialD.Interpreter.Base, TutorialD.Interpreter.DatabaseContextExpr, TutorialD.Interpreter.DatabaseContextIOOperator, TutorialD.Interpreter.Export.Base, TutorialD.Interpreter.Export.CSV, TutorialD.Interpreter.Import.Base, TutorialD.Interpreter.Import.BasicExamples, TutorialD.Interpreter.Import.CSV, TutorialD.Interpreter.Import.TutorialD, TutorialD.Interpreter.InformationOperator, TutorialD.Interpreter.RODatabaseContextOperator, TutorialD.Interpreter.RelationalExpr, TutorialD.Interpreter.SchemaOperator, TutorialD.Interpreter.TestBase, TutorialD.Interpreter.TransGraphRelationalOperator, TutorialD.Interpreter.TransactionGraphOperator, TutorialD.Interpreter.Types, TutorialD.Printer
release.nix+16−140
@@ -1,154 +1,30 @@
1−{ compiler ? "ghc865"
2−, pkgs ? import <nixpkgs> {}
1+{ compiler ? "ghc8104"
2+, sources ? import ./nix/sources.nix
3+, pkgs ? import sources.nixpkgs { }
34}:
4−
55let
6− inherit (pkgs.lib.trivial) flip pipe;
7− inherit (pkgs.haskell.lib) appendPatch appendConfigureFlags;
86 doJailbreak = pkgs.haskell.lib.doJailbreak;
9− dontHaddock = pkgs.haskell.lib.dontHaddock;
10− dontCheck = pkgs.haskell.lib.dontCheck;
11− streamly-master = pkgs.fetchFromGitHub {
12− owner = "composewell";
13− repo = "streamly";
14− rev = "ac3af8749194f1788704dda8667d0b3807075cc2";
15− sha256 = "04d8fk654vawdfs0dfidmq2awwgwi8x44iv8r7vqz70zkcsd5fij";
16− };
7+ needsCocoa = drv:
8+ if pkgs.stdenv.isDarwin
9+ then drv.overrideDerivation (old:
10+ { buildInputs = [ pkgs.darwin.apple_sdk.frameworks.Cocoa ] ++ old.buildInputs; }
11+ )
12+ else drv;
1713
18− distProcessPkg = pkg : dontHaddock (doJailbreak (dontCheck pkg));
19− callHackageDirectWithOptions = {pkg,ver, sha256, options}:
20− let pkgver = "${pkg}-${ver}";
21− in
22− haskellPackages.callCabal2nixWithOptions pkg (pkgs.fetchzip {
23− url = "mirror://hackage/${pkgver}/${pkgver}.tar.gz";
24− inherit sha256;
25− }) options;
26−
2714 haskellPackages = pkgs.haskell.packages.${compiler}.override {
2815 overrides = self: super: {
29− rank1dynamic =
30− distProcessPkg (self.callHackageDirect {
31− pkg = "rank1dynamic";
32− ver = "0.4.0";
33− sha256 = "1x6p9z53s7xwp93jp4n1lq6m5xspcn6w62p461v8vqnp9600328b";
34−}{});
35− stm-hamt =
36− distProcessPkg(self.callHackageDirect {
37− pkg = "stm-hamt";
38− ver = "1.2.0.3";
39− sha256 = "1i8j7q8nhx3l7gydrjlsyhkvllr6bppgrjf0hp38zpm7p6xcv2bb";
40− }{});
41−
42− stm-containers =
43− distProcessPkg(self.callHackageDirect {
44− pkg = "stm-containers";
45− ver = "1.1.0.4";
46− sha256 = "0h9z6lawdm44minx9spvdb7sp645l36ri5cnxvhrcxwzr64s7qb5";
47− }{});
48−
49− data-interval =
50− distProcessPkg(self.callHackageDirect {
51− pkg = "data-interval";
52− ver = "2.0.1";
53− sha256 = "085j4yjr8wimxampxqdrg47p577whwg2mjxgfdl44yfck52fb6an";
54− }{});
55−
56− rset = distProcessPkg super.rset;
57−
58− curryer-rpc =
59− distProcessPkg(self.callHackageDirect {
60− pkg = "curryer-rpc";
61− ver = "0.1";
62− sha256 = "0vb7q68g4zjm20simnqpjdpvcvh4g8cwlc5b6zjdjpg1rargri41";
63− }{});
64−
65− streamly = distProcessPkg(self.callCabal2nix "streamly" streamly-master {});
66−
67− fusion-plugin-types =
68− distProcessPkg(self.callHackageDirect {
69− pkg = "fusion-plugin-types";
70− ver = "0.1.0";
71− sha256 = "17211b80p4zqisghs2j8flm4dj788f9glx2id6nh8f223q4cigc9";
72− }{});
73−
74− winery =
75− distProcessPkg(self.callHackageDirect {
76− pkg = "winery";
77− ver = "1.3.2";
78− sha256 = "1jc7q8m0zd8bziwa3mra44j518ckc566akk7r5hqpf8x5ng0n4vv";
79− }{});
80−
81− barbies-th =
82− distProcessPkg(self.callHackageDirect {
83− pkg = "barbies-th";
84− ver = "0.1.7";
85− sha256 = "0gf39kcn6lwqhz888qm3iypma76yrp3zwmif1niry647qq27xp4j";
86− }{});
87−
88− barbies =
89− distProcessPkg(self.callHackageDirect {
90− pkg = "barbies";
91− ver = "2.0.2.0";
92− sha256 = "0753rd8pw0x1cgasz8a6633kg83jngwzncp9khbimllvcdqzardh";
93− }{});
94−
95− prettyprinter =
96− distProcessPkg(self.callHackageDirect {
97− pkg = "prettyprinter";
98− ver = "1.7.0";
99− sha256 = "17byy08brwcsl5rqdhibq3pcpgx085shizb2ap6s4xy3izdia3cc";
100− }{});
101−
102− prettyprinter-ansi-terminal =
103− distProcessPkg(self.callHackageDirect {
104− pkg = "prettyprinter-ansi-terminal";
105− ver = "1.1.2";
106− sha256 = "0lwcqndppw3jc55rlnn6sp76zmjx2yzl21g9jhg27k2rdnjwd7md";
107− }{});
108−
109− http2 = distProcessPkg super.http2;
110−
111− cryptohash-sha256 =
112− distProcessPkg(self.callHackageDirect {
113− pkg = "cryptohash-sha256";
114− ver = "0.11.101.0";
115− sha256 = "02n4s1fm4kivi5cjzbwkzjs31h5sw8zrv0vv2qyz3413zp3g6010";
116− }{});
117−
118− cryptohash-md5 =
119− distProcessPkg(self.callHackageDirect {
120− pkg = "cryptohash-md5";
121− ver = "0.11.100.1";
122− sha256 = "1l9l3c5x4759pa0ah48skzrkakb5738n6cw60ksj8pmzf68f428a";
123− }{});
124−
125− cryptohash-sha1 =
126− distProcessPkg(self.callHackageDirect {
127− pkg = "cryptohash-sha1";
128− ver = "0.11.100.1";
129− sha256 = "0k3q9sraq7s5y8i01p5a2b3cvbdvslz9kv494vh83jrvsamj7dcx";
130− }{});
131−
132− base16-bytestring =
133− distProcessPkg(self.callHackageDirect {
134− pkg = "base16-bytestring";
135− ver = "1.0.1.0";
136− sha256 = "0wvsjhg301qxikarvnvrbhdadrs892z4v8w9bq4na4gwdlf4aw6z";
137− }{});
138−
139− project-m36 = dontCheck (self.callCabal2nixWithOptions "project-m36" ./. "-f-haskell-scripting" { });
140−
16+ curryer-rpc = self.callCabal2nix "curryer-rpc" sources.curryer { };
17+ streamly = doJailbreak (needsCocoa (self.callCabal2nix "streamly" sources.streamly { }));
18+ project-m36 = ((self.callCabal2nixWithOptions "project-m36" ./. "-f-haskell-scripting" { }));
14119 };
14220 };
143−
144− project = haskellPackages.project-m36;
14521in
14622{
147− project = project;
23+ project = haskellPackages.project-m36;
14824
14925 shell = haskellPackages.shellFor {
150− packages = p: with p; [
151− project
26+ packages = p: [
27+ p.project-m36
15228 ];
15329 buildInputs = [
15430 haskellPackages.ghcid
@@ -157,4 +33,4 @@ in
15733 ];
15834 withHoogle = true;
15935 };
160−}
36+}
src/bin/ProjectM36/Server/WebSocket/websocket-server.hs+42−9
@@ -1,23 +1,40 @@
11{-# LANGUAGE CPP #-}
2−import ProjectM36.Server.WebSocket
3−import ProjectM36.Server.Config
4−import ProjectM36.Server.ParseArgs
5−import ProjectM36.Server
2+
63import Control.Concurrent
7−import qualified Network.WebSockets as WS
84import Control.Exception
5+import Control.Monad (when)
6+import Data.Maybe (isJust)
7+import Data.String (fromString)
8+import Network.HTTP.Types (status400)
99import Network.Socket
10+import Network.Wai (Application, responseLBS)
11+import Network.Wai.Handler.Warp
12+import Network.Wai.Handler.WarpTLS (runTLS, tlsSettings)
13+import qualified Network.Wai.Handler.WebSockets as WS
14+import Network.WebSockets (defaultConnectionOptions)
15+import ProjectM36.Server
16+import ProjectM36.Server.Config
17+import ProjectM36.Server.ParseArgs
18+import ProjectM36.Server.WebSocket
1019
1120main :: IO ()
1221main = do
1322 -- launch normal project-m36-server
1423 addressMVar <- newEmptyMVar
15− serverConfig <- parseConfigWithDefaults (defaultServerConfig { bindPort = 8000, bindHost = "127.0.0.1" })
24+ wsConfig <- parseWSConfigWithDefaults (defaultServerConfig {bindPort = 8000, bindHost = "127.0.0.1"})
25+
1626 --usurp the serverConfig for our websocket server and make the proxied server run locally
17− let wsHost = bindHost serverConfig
27+ let serverConfig = wsServerConfig wsConfig
28+ wsHost = bindHost serverConfig
1829 wsPort = bindPort serverConfig
1930 serverHost = "127.0.0.1"
2031 serverConfig' = serverConfig {bindPort = 0, bindHost = serverHost}
32+ configCertificateFile = tlsCertificatePath wsConfig
33+ configKeyFile = tlsKeyPath wsConfig
34+
35+ when (isJust configCertificateFile /= isJust configKeyFile) $
36+ throwIO $ ErrorCall "TLS_CERTIFICATE_PATH and TLS_KEY_PATH must be set in tandem"
37+
2138 _ <- forkFinally (launchServer serverConfig' (Just addressMVar) >> pure ()) (either throwIO pure)
2239 --wait for server to be listening
2340 addr <- takeMVar addressMVar
@@ -25,6 +42,22 @@ main = do
2542 case addr of
2643 SockAddrInet port' _ -> fromIntegral port'
2744 _ -> error "unsupported socket address (IPv4 only currently)"
28− --this built-in server is apparently not meant for production use, but it's easier to test than starting up the wai or snap interfaces
29− WS.runServer wsHost (fromIntegral wsPort) (websocketProxyServer port serverHost)
45+ wsApp = websocketProxyServer port serverHost
46+ waiApp = WS.websocketsOr defaultConnectionOptions wsApp backupApp
47+ settings = warpSettings wsHost (fromIntegral wsPort)
48+
49+ case (configCertificateFile, configKeyFile) of
50+ (Just certificate, Just key) -> runTLS (tlsSettings certificate key) settings waiApp
51+ _ -> runSettings settings waiApp
52+
53+backupApp :: Application
54+backupApp _ respond = respond $ responseLBS status400 [] "Not a WebSocket request"
3055
56+warpSettings :: HostName -> Port -> Settings
57+warpSettings host port =
58+ setHost (fromString host)
59+ . setPort port
60+ . setServerName "project-m36"
61+ . setTimeout 3600
62+ . setGracefulShutdownTimeout (Just 5)
63+ $ defaultSettings
src/lib/ProjectM36/Server/Config.hs+6
@@ -12,6 +12,12 @@ data ServerConfig = ServerConfig { persistenceStrategy :: PersistenceStrategy,
1212 }
1313 deriving (Show)
1414
15+data WebsocketServerConfig = WebsocketServerConfig { wsServerConfig :: ServerConfig,
16+ tlsCertificatePath :: Maybe String,
17+ tlsKeyPath :: Maybe String
18+ }
19+ deriving (Show)
20+
1521defaultServerConfig :: ServerConfig
1622defaultServerConfig = ServerConfig { persistenceStrategy = NoPersistence,
1723 checkFS = True,
src/lib/ProjectM36/Server/ParseArgs.hs+31−14
@@ -17,14 +17,14 @@ parseArgsWithDefaults defaults = ServerConfig <$>
1717 many parseGhcPkgPath <*>
1818 parseTimeout (perRequestTimeout defaults) <*>
1919 parseTestMode
20−
20+
2121parsePersistenceStrategy :: Parser PersistenceStrategy
2222parsePersistenceStrategy = CrashSafePersistence <$> (dbdirOpt <* fsyncOpt) <|>
2323 MinimalPersistence <$> dbdirOpt <|>
2424 pure NoPersistence
25− where
26− dbdirOpt = strOption (short 'd' <>
27− long "database-directory" <>
25+ where
26+ dbdirOpt = strOption (short 'd' <>
27+ long "database-directory" <>
2828 metavar "DIRECTORY" <>
2929 showDefaultWith show
3030 )
@@ -34,43 +34,60 @@ parsePersistenceStrategy = CrashSafePersistence <$> (dbdirOpt <* fsyncOpt) <|>
3434
3535parseTestMode :: Parser Bool
3636parseTestMode = flag True False (long "test-mode" <> hidden)
37−
38−parseCheckFS :: Parser Bool
37+
38+parseCheckFS :: Parser Bool
3939parseCheckFS = flag True False (long "disable-fscheck" <>
4040 help "Disable filesystem check for journaling.")
41−
41+
4242parseDatabaseName :: Parser DatabaseName
4343parseDatabaseName = strOption (short 'n' <>
4444 long "database" <>
4545 metavar "DATABASE_NAME")
4646
47−parseHostname :: Hostname -> Parser Hostname
47+parseHostname :: Hostname -> Parser Hostname
4848parseHostname defHostname = strOption (short 'h' <>
4949 long "hostname" <>
5050 metavar "HOST_NAME" <>
5151 value defHostname)
52−
52+
5353parsePort :: Port -> Parser Port
5454parsePort defPort = option auto (short 'p' <>
5555 long "port" <>
5656 metavar "PORT_NUMBER" <>
5757 value defPort)
58−
58+
5959parseGhcPkgPath :: Parser String
6060parseGhcPkgPath = strOption (long "ghc-pkg-dir" <>
6161 metavar "GHC_PACKAGE_DIRECTORY")
62−
63−parseTimeout :: Int -> Parser Int
62+
63+parseTimeout :: Int -> Parser Int
6464parseTimeout defTimeout = option auto (long "timeout" <>
6565 metavar "MICROSECONDS" <>
6666 value defTimeout)
6767
6868parseConfig :: IO ServerConfig
6969parseConfig = parseConfigWithDefaults defaultServerConfig
70−
70+
7171parseConfigWithDefaults :: ServerConfig -> IO ServerConfig
7272parseConfigWithDefaults defaults = execParser (info (parseArgsWithDefaults defaults <**> helpOption) idm)
7373
74+parseWSConfigWithDefaults :: ServerConfig -> IO WebsocketServerConfig
75+parseWSConfigWithDefaults defaults = execParser (info (parseWSArgsWithDefaults defaults <**> helpOption) idm)
76+
77+parseWSArgsWithDefaults :: ServerConfig -> Parser WebsocketServerConfig
78+parseWSArgsWithDefaults defaults = WebsocketServerConfig <$>
79+ parseArgsWithDefaults defaults <*>
80+ parseTlsCertificatePath <*>
81+ parseTlsKeyPath
82+
83+
84+parseTlsCertificatePath :: Parser (Maybe String)
85+parseTlsCertificatePath = optional $ strOption (long "tls-certificate-path" <>
86+ metavar "TLS_CERTIFICATE_PATH")
87+
88+parseTlsKeyPath :: Parser (Maybe String)
89+parseTlsKeyPath = optional $ strOption (long "tls-key-path" <>
90+ metavar "TLS_KEY_PATH")
7491
7592helpOption :: Parser (a -> a)
7693helpOption = abortOption helpText $ mconcat
@@ -80,6 +97,6 @@ helpOption = abortOption helpText $ mconcat
8097 where
8198#if MIN_VERSION_optparse_applicative(0,16,0)
8299 helpText = ShowHelpText Nothing
83−#else
100+#else
84101 helpText = ShowHelpText
85102#endif
src/lib/ProjectM36/Shortcuts.hs+1−1
@@ -60,7 +60,7 @@ instance KnownSymbol x => IsLabel x RelationalExpr where
6060--
6161-- ps. I don't understand the usage of "AttributeAndTypeNameExpr AttributeName TypeConstructor a"
6262instance (KnownSymbol x, Atomable a)=> IsLabel x (HaskAtomType a -> AttributeExpr) where
63− fromLabel atyn = NakedAttributeExpr (Attribute name atyn) . toAtomType''
63+ fromLabel = (NakedAttributeExpr . Attribute name) . toAtomType''
6464 where name = T.pack $ symbolVal @x Proxy
6565
6666-- (#a 1) :: ExtendTupleExpr
stack.ghc8.10.yamlnew file+19
@@ -0,0 +1,19 @@
1+resolver: lts-17.13
2+packages:
3+ - "."
4+
5+extra-deps:
6+ - git: https://github.com/agentm/curryer.git
7+ commit: 74ecaac619ad1165a4517d5c0f4e530493bda130
8+ - git: https://github.com/composewell/streamly.git
9+ commit: ac3af8749194f1788704dda8667d0b3807075cc2
10+ - fast-builder-0.1.2.1
11+ - rset-1.0.0
12+ - winery-1.3.2
13+ - barbies-th-0.1.8
14+ - base16-bytestring-1.0.1.0
15+
16+flags:
17+ project-m36:
18+ stack: true
19+# allow-newer: true
stack.ghc8.6.yaml+24−24
@@ -6,32 +6,32 @@ resolver: lts-14.27
66
77# Local packages, usually specified by relative directory name
88packages:
9−- '.'
9+ - "."
1010# Packages to be pulled from upstream that are not in the resolver (e.g., acme-missiles-0.3)
1111extra-deps:
12−- git: https://github.com/agentm/curryer.git
13− commit: 28ff1d031078af4a17fa326d43340474571df0c3
14−- git: https://github.com/composewell/streamly.git
15− commit: ac3af8749194f1788704dda8667d0b3807075cc2
16−- fast-builder-0.1.2.1
17−- winery-1.3.2
18−- barbies-2.0.2.0
19−- barbies-th-0.1.7
20−- extended-reals-0.2.3.0
21−- data-interval-2.0.1
22−- stm-containers-1.1.0.4
23−- stm-hamt-1.2.0.4
24−- rset-1.0.0
25−- hashable-time-0.2.0.2
26−- network-transport-tcp-0.6.0
27−- megaparsec-7.0.5
28−- prettyprinter-1.7.0
29−- prettyprinter-ansi-terminal-1.1.2
30−- fusion-plugin-types-0.1.0
31−- base16-bytestring-1.0.1.0
32−- modern-uri-0.3.4.0
33−- cryptohash-sha256-0.11.102.0
34−- http-types-0.12.3
12+ - git: https://github.com/agentm/curryer.git
13+ commit: 74ecaac619ad1165a4517d5c0f4e530493bda130
14+ - git: https://github.com/composewell/streamly.git
15+ commit: ac3af8749194f1788704dda8667d0b3807075cc2
16+ - fast-builder-0.1.2.1
17+ - winery-1.3.2
18+ - barbies-2.0.2.0
19+ - barbies-th-0.1.7
20+ - extended-reals-0.2.3.0
21+ - data-interval-2.0.1
22+ - stm-containers-1.1.0.4
23+ - stm-hamt-1.2.0.4
24+ - rset-1.0.0
25+ - hashable-time-0.2.0.2
26+ - network-transport-tcp-0.6.0
27+ - megaparsec-7.0.5
28+ - prettyprinter-1.7.0
29+ - prettyprinter-ansi-terminal-1.1.2
30+ - fusion-plugin-types-0.1.0
31+ - base16-bytestring-1.0.1.0
32+ - modern-uri-0.3.4.0
33+ - cryptohash-sha256-0.11.102.0
34+ - http-types-0.12.3
3535
3636# Override default flag values for local packages and extra-deps
3737flags:
stack.ghc8.8.yaml+24−24
@@ -6,32 +6,32 @@ resolver: lts-16.4
66
77# Local packages, usually specified by relative directory name
88packages:
9−- '.'
9+ - "."
1010# Packages to be pulled from upstream that are not in the resolver (e.g., acme-missiles-0.3)
1111extra-deps:
12−- git: https://github.com/agentm/curryer.git
13− commit: 28ff1d031078af4a17fa326d43340474571df0c3
14−- git: https://github.com/composewell/streamly.git
15− commit: ac3af8749194f1788704dda8667d0b3807075cc2
16−- fast-builder-0.1.2.1
17−- winery-1.3.2
18−- barbies-2.0.2.0
19−- barbies-th-0.1.7
20−- extended-reals-0.2.3.0
21−- data-interval-2.0.1
22−- stm-containers-1.1.0.4
23−- stm-hamt-1.2.0.4
24−- rset-1.0.0
25−- hashable-time-0.2.0.2
26−- network-transport-tcp-0.7.0
27−- megaparsec-7.0.5
28−- network-2.8.0.1
29−- primitive-extras-0.8
30−- primitive-unlifted-0.1.3.0
31−- prettyprinter-1.7.0
32−- prettyprinter-ansi-terminal-1.1.2
33−- base16-bytestring-1.0.1.0
34−- modern-uri-0.3.4.0
12+ - git: https://github.com/agentm/curryer.git
13+ commit: 74ecaac619ad1165a4517d5c0f4e530493bda130
14+ - git: https://github.com/composewell/streamly.git
15+ commit: ac3af8749194f1788704dda8667d0b3807075cc2
16+ - fast-builder-0.1.2.1
17+ - winery-1.3.2
18+ - barbies-2.0.2.0
19+ - barbies-th-0.1.7
20+ - extended-reals-0.2.3.0
21+ - data-interval-2.0.1
22+ - stm-containers-1.1.0.4
23+ - stm-hamt-1.2.0.4
24+ - rset-1.0.0
25+ - hashable-time-0.2.0.2
26+ - network-transport-tcp-0.7.0
27+ - megaparsec-7.0.5
28+ - network-2.8.0.1
29+ - primitive-extras-0.8
30+ - primitive-unlifted-0.1.3.0
31+ - prettyprinter-1.7.0
32+ - prettyprinter-ansi-terminal-1.1.2
33+ - base16-bytestring-1.0.1.0
34+ - modern-uri-0.3.4.0
3535
3636# Override default flag values for local packages and extra-deps
3737flags:
test/TutorialD/Interpreter/Import/TutorialD.hs → test/TutorialD/Interpreter/Import/ImportTest.hsrenamed

The content is the same.

test/TutorialD/Interpreter.hs → test/TutorialD/InterpreterTest.hsrenamed

The content is the same.

test/TutorialD/Printer.hs → test/TutorialD/PrinterTest.hsrenamed

The content is the same.