Skip to content

Commit 242ceee

Browse files
committed
new: add flake.nix
1 parent 39317da commit 242ceee

File tree

22 files changed

+785
-156
lines changed

22 files changed

+785
-156
lines changed

Space.cabal

Lines changed: 0 additions & 71 deletions
This file was deleted.

app/Main.hs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11
module Main where
22

3+
import Space.Evaluator
4+
import Space.Syntax.Parser
5+
import Prettyprinter
6+
37
main :: IO ()
4-
main = putStrLn "Hello, Haskell!"
8+
main = do
9+
putStrLn "Hello, Haskell!"
10+
content <- readFile "test/Examples/example-terms.sp"
11+
case parseTerm content of
12+
Left e -> error $ show e
13+
Right term -> do
14+
res <- evalTerm term
15+
case res of
16+
Right e -> (print . pretty) e
17+
Left e -> print e

cabal.project

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

flake.lock

Lines changed: 42 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
description = "Space Lang";
3+
inputs = {
4+
nixpkgs.url = "github:nixos/nixpkgs";
5+
flake-utils.url = "github:numtide/flake-utils";
6+
};
7+
outputs = inputs@{ self, nixpkgs, flake-utils, ... }:
8+
flake-utils.lib.eachDefaultSystem (system:
9+
let
10+
overlays = [ ];
11+
12+
pkgs = import nixpkgs {
13+
inherit system overlays;
14+
# config.allowBroken = true;
15+
};
16+
17+
additionalPckgs = with pkgs; [ nixfmt rlwrap ];
18+
19+
additionalHaskellPckgs = with pkgs.haskellPackages; [
20+
stack
21+
structured-haskell-mode
22+
stylish-haskell
23+
apply-refact
24+
cabal-fmt
25+
cabal-install
26+
fourmolu
27+
ghcid
28+
hasktags
29+
hlint
30+
zlib
31+
haskell-language-server
32+
doctest
33+
];
34+
35+
project = returnShellEnv:
36+
pkgs.haskellPackages.developPackage {
37+
inherit returnShellEnv;
38+
name = "space-lang";
39+
root = self;
40+
withHoogle = true;
41+
modifier = drv:
42+
pkgs.haskell.lib.addBuildTools drv
43+
(additionalHaskellPckgs ++ additionalPckgs);
44+
};
45+
in {
46+
47+
# Used by `nix build` & `nix run` (prod exe)
48+
defaultPackage = project false;
49+
50+
# Used by `nix develop` (dev shell)
51+
devShell = project true;
52+
});
53+
}

space-lang.cabal

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
cabal-version: 3.4
2+
name: space-lang
3+
version: 0.1.0.0
4+
author: Vlad Posmangiu Luchian
5+
maintainer: [email protected]
6+
extra-source-files: CHANGELOG.md
7+
8+
common space-common
9+
ghc-options:
10+
-Wall -Wcompat -Wincomplete-uni-patterns -Wno-unused-do-bind
11+
-Wno-partial-type-signatures -Wmissing-export-lists
12+
-Wincomplete-record-updates -Wmissing-deriving-strategies
13+
-Wno-name-shadowing -Wunused-foralls
14+
-Wno-unticked-promoted-constructors -fprint-explicit-foralls
15+
-fprint-explicit-kinds
16+
17+
-- -Werror
18+
build-depends:
19+
, base ^>=4.15.1.0
20+
, containers ^>=0.6.6
21+
, freer-simple ^>=1.2.1.2
22+
, lens ^>=5.2
23+
, parsec ^>=3.1.15.1
24+
, prettyprinter ^>=1.7.1
25+
, mtl
26+
, transformers
27+
28+
default-extensions:
29+
DataKinds
30+
DerivingStrategies
31+
FlexibleContexts
32+
GADTs
33+
GeneralizedNewtypeDeriving
34+
LambdaCase
35+
OverloadedStrings
36+
RankNTypes
37+
ScopedTypeVariables
38+
TemplateHaskell
39+
TypeApplications
40+
TypeOperators
41+
NumericUnderscores
42+
43+
executable space-lang
44+
import: space-common
45+
main-is: Main.hs
46+
build-depends: space-lang
47+
hs-source-dirs: app
48+
default-language: Haskell2010
49+
50+
executable spci
51+
import: space-common
52+
main-is: spci.hs
53+
build-depends: space-lang
54+
hs-source-dirs: spci
55+
default-language: Haskell2010
56+
57+
library
58+
import: space-common
59+
hs-source-dirs: src
60+
exposed-modules:
61+
Space.Evaluator
62+
Space.Parser
63+
Space.Syntax.Parser
64+
Space.Syntax.Types
65+
Space.Syntax.Context
66+
Space.TypeChecking.Derivation
67+
Space.TypeChecking.Derive
68+
Space.Syntax
69+
70+
test-suite test
71+
import: space-common
72+
type: exitcode-stdio-1.0
73+
main-is: Test.hs
74+
hs-source-dirs: test
75+
build-depends: space-lang
76+
exposed-modules: Space.Test.Parser
77+
other-modules:
78+
Examples.ExampleTerms
79+
Space.Test.Parser
80+
build-depends:
81+
, tasty
82+
, tasty-hunit

spci/spci.hs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
module Main where
2+
3+
import Space.Evaluator
4+
import Space.Syntax.Parser
5+
import Space.Syntax.Types
6+
import Prettyprinter
7+
8+
main :: IO ()
9+
main = do
10+
putStrLn "Hello, Haskell!"
11+
repl (mempty,mempty)
12+
13+
repl :: (Bindings, Stacks) -> IO ()
14+
repl mem = do
15+
content <- getLine
16+
case parseTerm content of
17+
Left e -> do
18+
print e
19+
repl mem
20+
Right term -> do
21+
computationResult <- runEval' mem term
22+
case computationResult of
23+
Left e -> print e >> repl mem
24+
Right res@(_,newMem) -> do (print . pretty) res >> repl newMem

0 commit comments

Comments
 (0)