Skip to content

Commit 2a89b1d

Browse files
author
Sven Tennie
committed
Add 'stack' project for literate programming
1 parent 9e0ff7f commit 2a89b1d

9 files changed

+580
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@
66
*.out
77
*.snm
88
*.toc
9+
.stack-work/
10+
lambda-calculus-presentation.cabal
11+
*~

LICENSE

+428
Large diffs are not rendered by default.

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# lambda-calculus-presentation

Setup.hs

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import Distribution.Simple
2+
main = defaultMain

package.yaml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: lambda-calculus-presentation
2+
version: 0.1.0.0
3+
github: "supersven/lambda-calculus-presentation"
4+
author: "Sven Tennie"
5+
maintainer: "[email protected]"
6+
copyright: "2018 - Sven Tennie"
7+
8+
extra-source-files:
9+
- README.md
10+
11+
# Metadata used when publishing your package
12+
# synopsis: Short description of your package
13+
# category: Web
14+
15+
# To avoid duplicated efforts in documentation and dealing with the
16+
# complications of embedding Haddock markup inside cabal files, it is
17+
# common to point users to the README.md file.
18+
description: Please see the README on GitHub at <https://github.com/supersven/lambda-calculus-presentation#readme>
19+
20+
dependencies:
21+
- base >= 4.7 && < 5
22+
23+
library:
24+
source-dirs: src
25+
dependencies: containers >= 0.5.10.2
26+
27+
tests:
28+
lambda-calculus-presentation-test:
29+
main: Spec.hs
30+
source-dirs: test
31+
ghc-options:
32+
- -threaded
33+
- -rtsopts
34+
- -with-rtsopts=-N
35+
dependencies:
36+
- lambda-calculus-presentation

presentation_2.org

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#+BEGIN_SRC haskell :tangle src/UntypedEval.hs
2+
module UntypedEval where
3+
import qualified Data.Map.Strict as Map
4+
5+
type Name = String
6+
type Environment = Map.Map Name Term
7+
8+
data Term = Variable Name |
9+
Application Term Term |
10+
Abstraction Name Term
11+
deriving (Eq, Show)
12+
13+
eval ::Environment -> Term -> Maybe Term
14+
eval env (Variable name) = find env name
15+
eval env (Application term1 term2) = case term1 of
16+
(Abstraction name _) -> eval (Map.insert name term2 env) term1
17+
_ -> Nothing
18+
eval _ abstraction@(Abstraction _ _) = Just abstraction
19+
20+
find :: Environment -> Name -> Maybe Term
21+
find env name = Map.lookup name env
22+
#+END_SRC

src/UntypedEval.hs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module UntypedEval where
2+
import qualified Data.Map.Strict as Map
3+
4+
type Name = String
5+
type Environment = Map.Map Name Term
6+
7+
data Term = Variable Name |
8+
Application Term Term |
9+
Abstraction Name Term
10+
deriving (Eq, Show)
11+
12+
eval ::Environment -> Term -> Maybe Term
13+
eval env (Variable name) = find env name
14+
eval env (Application term1 term2) = case term1 of
15+
(Abstraction name _) -> eval (Map.insert name term2 env) term1
16+
_ -> Nothing
17+
eval _ abstraction@(Abstraction _ _) = Just abstraction
18+
19+
find :: Environment -> Name -> Maybe Term
20+
find env name = Map.lookup name env

stack.yaml

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# This file was automatically generated by 'stack init'
2+
#
3+
# Some commonly used options have been documented as comments in this file.
4+
# For advanced use and comprehensive documentation of the format, please see:
5+
# https://docs.haskellstack.org/en/stable/yaml_configuration/
6+
7+
# Resolver to choose a 'specific' stackage snapshot or a compiler version.
8+
# A snapshot resolver dictates the compiler version and the set of packages
9+
# to be used for project dependencies. For example:
10+
#
11+
# resolver: lts-3.5
12+
# resolver: nightly-2015-09-21
13+
# resolver: ghc-7.10.2
14+
# resolver: ghcjs-0.1.0_ghc-7.10.2
15+
# resolver:
16+
# name: custom-snapshot
17+
# location: "./custom-snapshot.yaml"
18+
resolver: lts-11.21
19+
20+
# User packages to be built.
21+
# Various formats can be used as shown in the example below.
22+
#
23+
# packages:
24+
# - some-directory
25+
# - https://example.com/foo/bar/baz-0.0.2.tar.gz
26+
# - location:
27+
# git: https://github.com/commercialhaskell/stack.git
28+
# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a
29+
# - location: https://github.com/commercialhaskell/stack/commit/e7b331f14bcffb8367cd58fbfc8b40ec7642100a
30+
# extra-dep: true
31+
# subdirs:
32+
# - auto-update
33+
# - wai
34+
#
35+
# A package marked 'extra-dep: true' will only be built if demanded by a
36+
# non-dependency (i.e. a user package), and its test suites and benchmarks
37+
# will not be run. This is useful for tweaking upstream packages.
38+
packages:
39+
- .
40+
# Dependency packages to be pulled from upstream that are not in the resolver
41+
# (e.g., acme-missiles-0.3)
42+
# extra-deps: []
43+
44+
# Override default flag values for local packages and extra-deps
45+
# flags: {}
46+
47+
# Extra package databases containing global packages
48+
# extra-package-dbs: []
49+
50+
# Control whether we use the GHC we find on the path
51+
# system-ghc: true
52+
#
53+
# Require a specific version of stack, using version ranges
54+
# require-stack-version: -any # Default
55+
# require-stack-version: ">=1.6"
56+
#
57+
# Override the architecture used by stack, especially useful on Windows
58+
# arch: i386
59+
# arch: x86_64
60+
#
61+
# Extra directories used by stack for building
62+
# extra-include-dirs: [/path/to/dir]
63+
# extra-lib-dirs: [/path/to/dir]
64+
#
65+
# Allow a newer minor version of GHC than the snapshot specifies
66+
# compiler-check: newer-minor

test/Spec.hs

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
main :: IO ()
2+
main = putStrLn "Test suite not yet implemented"

0 commit comments

Comments
 (0)