--- /dev/null
+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
 
--- /dev/null
+*.actual.*
+*.eventlog
+*.eventlog
+*.eventlog.html
+*.eventlog.json
+*.hi
+*.hp
+*.o
+*.prof
+*.root
+.direnv/
+.ghc.environment.*
+.stack-work/
+dist-newstyle/
+dump-core/
+result*
 
 -- 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
 
 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
 
+{-# 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.
 
+{-# OPTIONS_GHC -Wno-orphans #-}
 -- | Semantics for Identity (aka. R, or meta-circular representation).
 module SemanticEval where
 
 
 {-# LANGUAGE FlexibleInstances #-}
 {-# LANGUAGE TemplateHaskell #-}
+{-# OPTIONS_GHC -Wno-orphans #-}
 -- | Semantics for TemplateHaskell
 module SemanticSplice where
 
 
--- /dev/null
+packages:.
 
--- /dev/null
+{ pkgs ? import <nixpkgs> {}
+, 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;
+  };
+}
 
--- /dev/null
+{
+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;
+    }
+  );
+}
 
--- /dev/null
+(import ./. {}).shell
 
--- /dev/null
+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