From 9b58b0edab76a7299dbb81db78da512e301a6ddc Mon Sep 17 00:00:00 2001 From: Julien Moutinho Date: Sun, 16 May 2021 06:08:03 +0200 Subject: [PATCH] add nix files --- .envrc | 12 ++++++++++++ .gitignore | 16 ++++++++++++++++ Examples.hs | 4 ++-- Makefile | 8 ++++---- SemanticAlp.hs | 3 ++- SemanticEval.hs | 1 + SemanticSplice.hs | 1 + cabal.project | 1 + default.nix | 27 +++++++++++++++++++++++++++ flake.nix | 12 ++++++++++++ shell.nix | 1 + symantic-reify.cabal | 32 ++++++++++++++++++++++++++++++++ 12 files changed, 111 insertions(+), 7 deletions(-) create mode 100644 .envrc create mode 100644 .gitignore create mode 100644 cabal.project create mode 100644 default.nix create mode 100644 flake.nix create mode 100644 shell.nix create mode 100644 symantic-reify.cabal diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..324cf67 --- /dev/null +++ b/.envrc @@ -0,0 +1,12 @@ +use_flake() { + watch_file flake.nix + watch_file flake.lock + watch_file default.nix + watch_file shell.nix + profile="$(direnv_layout_dir)"/flake-profile + mkdir -p "$(direnv_layout_dir)" + eval "$(time nix print-dev-env --show-trace --profile "$profile" || echo false)" && + nix-store --add-root "shell.root" --indirect --realise "$profile" && + nix-env --delete-generations +1 --profile "$profile" +} +use flake diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..886d3f4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,16 @@ +*.actual.* +*.eventlog +*.eventlog +*.eventlog.html +*.eventlog.json +*.hi +*.hp +*.o +*.prof +*.root +.direnv/ +.ghc.environment.* +.stack-work/ +dist-newstyle/ +dump-core/ +result* diff --git a/Examples.hs b/Examples.hs index 776de87..bbda619 100644 --- a/Examples.hs +++ b/Examples.hs @@ -7,8 +7,8 @@ module Examples where -- Their only constraint is to have only arguments whose type is *polymorphic* -- (possibly with contraints or type parameters though). --- Note the beta-reductible 'w', it will be normalized-out. -e0 = \x y z -> x / y + y + 2 * z + (\w -> y) z +-- Note the beta-reductible '_w', it will be normalized-out. +e0 = \x y z -> x / y + y + 2 * z + (\_w -> y) z -- Note that 'f' is a function: arguments can be functions. e1 = \f x -> f x diff --git a/Makefile b/Makefile index 8214944..7825d53 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ all: - runhaskell Main.hs -ghcid: - ghcid -c 'ghci Main.hs -ignore-dot-ghci -package template-haskell' --reverse-errors + cabal run ghci: - ghci -package template-haskell Main.hs + cabal repl +ghcid: + ghcid -c 'cabal repl --ghc-options -ignore-dot-ghci' --reverse-errors diff --git a/SemanticAlp.hs b/SemanticAlp.hs index ad350a3..0e22317 100644 --- a/SemanticAlp.hs +++ b/SemanticAlp.hs @@ -1,8 +1,9 @@ +{-# OPTIONS_GHC -Wno-orphans #-} -- | Semantics for Alp's Expr module SemanticAlp where import Syntax -import qualified Control.Monad.State.Strict as MT +import qualified Control.Monad.Trans.State.Strict as MT -- | An untyped expression. -- This is only to keep Alp's initial algebra for the demo. diff --git a/SemanticEval.hs b/SemanticEval.hs index a20b605..999ac74 100644 --- a/SemanticEval.hs +++ b/SemanticEval.hs @@ -1,3 +1,4 @@ +{-# OPTIONS_GHC -Wno-orphans #-} -- | Semantics for Identity (aka. R, or meta-circular representation). module SemanticEval where diff --git a/SemanticSplice.hs b/SemanticSplice.hs index fc7f198..f5d71d9 100644 --- a/SemanticSplice.hs +++ b/SemanticSplice.hs @@ -1,5 +1,6 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE TemplateHaskell #-} +{-# OPTIONS_GHC -Wno-orphans #-} -- | Semantics for TemplateHaskell module SemanticSplice where diff --git a/cabal.project b/cabal.project new file mode 100644 index 0000000..dc68224 --- /dev/null +++ b/cabal.project @@ -0,0 +1 @@ +packages:. diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..d2821c1 --- /dev/null +++ b/default.nix @@ -0,0 +1,27 @@ +{ pkgs ? import {} +, ghc ? "ghc901" +, withHoogle ? false +}: +let + haskellPackages = + if ghc == null + then pkgs.haskellPackages + else pkgs.haskell.packages.${ghc}; + hs = haskellPackages.extend (with pkgs.haskell.lib; hself: hsuper: + { + symantic-reify = buildFromSdist (hself.callCabal2nix "symantic-reify" ./. {}); + } + ); +in hs.symantic-reify // { + shell = hs.shellFor { + doBenchmark = true; + packages = p: [ p.symantic-reify ]; + nativeBuildInputs = [ + hs.cabal-install + hs.ghcid + ]; + buildInputs = [ + ]; + inherit withHoogle; + }; +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..494305f --- /dev/null +++ b/flake.nix @@ -0,0 +1,12 @@ +{ +inputs.nixpkgs.url = "flake:nixpkgs"; +inputs.flake-utils.url = "github:numtide/flake-utils"; +outputs = inputs: + inputs.flake-utils.lib.eachDefaultSystem (system: let + pkgs = inputs.nixpkgs.legacyPackages.${system}; + in { + defaultPackage = import ./default.nix { inherit pkgs; }; + devShell = (import ./default.nix { inherit pkgs; }).shell; + } + ); +} diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..0d9af5e --- /dev/null +++ b/shell.nix @@ -0,0 +1 @@ +(import ./. {}).shell diff --git a/symantic-reify.cabal b/symantic-reify.cabal new file mode 100644 index 0000000..e6660c6 --- /dev/null +++ b/symantic-reify.cabal @@ -0,0 +1,32 @@ +cabal-version: 3.0 +name: symantic-reify +version: 0.0.0 +tested-with: GHC==9.0.1 + +executable symantic-preify + type: exitcode-stdio-1.0 + default-language: Haskell98 + ghc-options: + -Wall + -Wincomplete-uni-patterns + -Wincomplete-record-updates + -Wpartial-fields + -Wno-type-defaults + -Wno-missing-signatures + -fprint-potential-instances + main-is: Main.hs + other-modules: + Examples + Reify + SemanticAlp + SemanticEval + SemanticSplice + Syntax + Tests + TestsSplice + ghc-options: + -- -O2 -fno-enable-th-splice-warnings + build-depends: + base >= 4.6 && < 5, + template-haskell >= 2.16, + transformers >= 0.5 -- 2.42.0