Skip to content

Commit

Permalink
New compiler (lts-12.1).
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel-fallen committed Jul 26, 2018
1 parent 8d042af commit 28290ae
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
4 changes: 2 additions & 2 deletions krivine-extended.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
--
-- see: https://github.com/sol/hpack
--
-- hash: d160341675b1544a464a29764a7dbd1ee39fddd0b734385284878ddc1453c392
-- hash: bbd30a36925072562658c1138ed5f7979442d6821e20fc98a1a543e671bd468a

name: krivine-extended
version: 0.1.0.0
Expand All @@ -25,7 +25,7 @@ executable extended
Paths_krivine_extended
hs-source-dirs:
src
ghc-options: -O2 -rtsopts -threaded -with-rtsopts=-N
ghc-options: -O2 -rtsopts -threaded -with-rtsopts=-N -fno-prof-count-entries -eventlog
build-depends:
base >=4.7 && <5
, deepseq
Expand Down
2 changes: 1 addition & 1 deletion package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dependencies:
- deepseq
- parallel

ghc-options: -O2 -rtsopts -threaded -with-rtsopts=-N
ghc-options: -O2 -rtsopts -threaded -with-rtsopts=-N -fno-prof-count-entries -eventlog

executables:
extended:
Expand Down
6 changes: 6 additions & 0 deletions src/Lib.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ instance Show Term where
show (App u v) = '(' : show u ++ ") " ++ show v
show (Free n) = n

size :: Term -> Integer
size (Var _) = 1
size (Lam t) = 1 + size t
size (App u v) = 1 + size u + size v
size (Free _) = 1


data Closure = Closure
{ getTerm :: !Term
Expand Down
18 changes: 11 additions & 7 deletions src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ testt n m = foldl App (Free "z") $ replicate m $ nid n

--

-- | church k = \f.\z.(f)^{k}z -- Church numeral @k@
church :: Int -> Term
church k = Lam $ Lam $ iterate (App (Var 1)) (Var 0) !! k

Expand All @@ -61,15 +62,13 @@ nmpair n m = App (App t $ u n) $ u m
where
-- t = \x.\y.((a)(x)y)(b)(y)x
t = Lam $ Lam $ App (App (Free "a") $ App (Var 1) (Var 0)) $ App (Free "b") $ App (Var 0) (Var 1)
-- u k = \f.\z.(f)^{k}z -- Church numeral @k@
u = church

klmn :: Int -> Int -> Int -> Int -> Term
klmn k l m n = App (App (App (App t $ u k) $ u l) $ u m) $ u n
where
-- t = \x1.\x2.\x3.\x4.((((a)(x1)x2) (b)(x2)x1) (c)(x3)x4) (d)(x4)x3
t = Lam $ Lam $ Lam $ Lam $ foldl App (Free "a") [App (Var 3) (Var 2), App (Free "b") $ App (Var 2) (Var 3), App (Free "c") $ App (Var 1) (Var 0), App (Free "d") $ App (Var 0) (Var 1)]
-- u k = \f.\z.(f)^{k}z -- Church numeral @k@
u = church

sixTuple :: Int -> Int -> Term
Expand All @@ -78,6 +77,9 @@ sixTuple n m = App t u
t = Lam $ foldl App (Free "y") [Var 0, Var 0, Var 0, Var 0, Var 0, Var 0]
u = App (App (Free "x") $ App (church n) (church m)) $ App (church m) (church n)

-- ((x)((\\(((2)\\(1)2)\\\(2)1)((1)\\(1)2)\\\1)(y1)y2)(y3)y4)((\\(((2)\\(1)2)\\\(2)1)((1)\\(1)2)\\\1)(y5)y6)(y7)y8


main :: IO ()
main = do
let end = Free "end"
Expand All @@ -90,9 +92,10 @@ main = do
r21' = eval' add21'
big = eval' $ testt 15000 2000
pair23 = eval' $ nmpair 2 3
pair88 = eval' $ nmpair 8 8
pair76 = eval' $ nmpair 7 6
klmn8776 = eval' $ klmn 8 7 7 6
tuple86 = eval' $ sixTuple 8 6
klmn6776 = eval' $ klmn 6 7 7 6
tuple86 = eval' $ sixTuple 9 6
-- print r1
-- putStrLn $ if r1 == end then "pass" else "fail"
-- print r2
Expand All @@ -107,7 +110,8 @@ main = do
-- print $ eval' $ App c2 c2
-- print big
-- print pair23 -- for visual examination
-- pair88 `deepseq` putStrLn "Done."
-- klmn8776 `deepseq` putStrLn "Done."
-- pair76 `deepseq` putStrLn "Done."
klmn8776 `deepseq` putStrLn "Done."
-- klmn6776 `deepseq` putStrLn "Done."
-- print $ sixTuple 2 3
tuple86 `deepseq` putStrLn "Done."
-- tuple86 `deepseq` putStrLn "Done."
2 changes: 1 addition & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#
# resolver: ./custom-snapshot.yaml
# resolver: https://example.com/snapshots/2018-01-01.yaml
resolver: lts-11.12
resolver: lts-12.1

# User packages to be built.
# Various formats can be used as shown in the example below.
Expand Down

0 comments on commit 28290ae

Please sign in to comment.