diff --git a/.gitignore b/.gitignore index fdf5d3c..ef7fc1c 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ dist-newstyle/ .cabal-sandbox .stack-work .cabal.sandbox.config +.envrc diff --git a/examples/open_rec_version0.hs b/examples/open_rec_version0.hs new file mode 100644 index 0000000..bd8d828 --- /dev/null +++ b/examples/open_rec_version0.hs @@ -0,0 +1,15 @@ +object = (\f -> f (@object f)) + +mkCounter = (\this -> \n -> + Counter (this (add 1 n)) n + ) + +tick = (\c -> case c of { + Counter t d -> t + }) + +value = (\c -> case c of { + Counter t d -> d + }) + +main = @value (@tick (@tick (@object @mkCounter 0))) diff --git a/examples/open_rec_version1.hs b/examples/open_rec_version1.hs new file mode 100644 index 0000000..f1c63cc --- /dev/null +++ b/examples/open_rec_version1.hs @@ -0,0 +1,20 @@ +object = (\f -> f (@object f)) + +mkCounter = (\this -> \n -> + Counter (this (add 1 n)) n + ) + +faster = (\this -> \n -> + let c = @mkCounter this n + in Counter (this (add 2 n)) (@value c) + ) + +tick = (\c -> case c of { + Counter t d -> t + }) + +value = (\c -> case c of { + Counter t d -> d + }) + +main = @value (@tick (@tick (@object @faster 0))) diff --git a/examples/open_rec_version2.hs b/examples/open_rec_version2.hs new file mode 100644 index 0000000..2bb1746 --- /dev/null +++ b/examples/open_rec_version2.hs @@ -0,0 +1,24 @@ +object = (\f -> f undefined (@object f)) + +mkCounter = (\super -> \this -> \n -> + Counter (this (add 1 n)) n + ) + +faster = (\super -> \this -> \n -> + let c = super n + in Counter (this (add 2 n)) (@value c) + ) + +tick = (\c -> case c of { + Counter t d -> t + }) + +value = (\c -> case c of { + Counter t d -> d + }) + +mixin = (\f -> \g -> \super -> \this -> + f (g super this) this + ) + +main = @value (@tick (@tick (@object (@mixin @faster @mkCounter) 0))) diff --git a/minimal.html b/minimal.html index 7331ede..05af18d 100644 --- a/minimal.html +++ b/minimal.html @@ -9,7 +9,6 @@
Term |
Heap |
Graph |