packages feed

funcons-lambda-cbv-mp 0.1.0.0 → 0.1.0.2

raw patch · 47 files changed

+429/−4 lines, 47 filesdep ~basedep ~funcons-tools

Dependency ranges changed: base, funcons-tools

Files

+ README.txt view
@@ -0,0 +1,17 @@+Tested on Ubuntu 14.04++INSTALL++   cabal build++RUN++   dist/build/lambda-cbv/lambda-cbv <PATH>++For example: dist/build/lambda-cbv/lambda-cbv programs/fib-double-cbna.cbv++TESTS++   ./run-tests.sh++should produce the same output provided in full.output
+ full.output view
@@ -0,0 +1,183 @@+programs/fib-clash2-cbne.cbv:+Result:+26++Output Entity: standard-out+7,5,3,1,2,4,2,3,1,2,6,4,2,3,1,2,5,3,1,2,4,2,3,1,2+programs/ct-eval.cbv:+Result:+0+programs/ast-output.cbv:+Result:+3++Output Entity: standard-out+3+programs/ast-app.cbv:+Result:+7+programs/mp6.cbv:+Result:+42+programs/letdown-product-static.cbv:+Result:+24+programs/mp3.cbv:+Result:+5++Output Entity: standard-out+5+programs/fib-const-cbne.cbv:+Result:+42+programs/fib-double-cbne.cbv:+Result:+26++Output Entity: standard-out+7,5,3,1,2,4,2,3,1,2,6,4,2,3,1,2,5,3,1,2,4,2,3,1,2+programs/basics2.cbv:+Result:+5+programs/comparison1b.cbv:+Result:+14++Output Entity: standard-out+1,0,1,0+programs/mp4.cbv:+Result:+10+programs/fib-double-cbv2.cbv:+Result:+26++Output Entity: standard-out+7,5,3,1,2,4,2,3,1,2,6,4,2,3,1,2,5,3,1,2,4,2,3,1,2+programs/fib-clash2-cbna2.cbv:+Result:+26++Output Entity: standard-out+7,5,3,1,2,4,2,3,1,2,6,4,2,3,1,2,5,3,1,2,4,2,3,1,2,7,5,3,1,2,4,2,3,1,2,6,4,2,3,1,2,5,3,1,2,4,2,3,1,2+programs/comparison1c.cbv:+Result:+14++Output Entity: standard-out+1,0+programs/ast-from-downml.cbv:+Result:+astv(integer-add,astv(naturals,3),astv(naturals,4))+programs/fib-clash-cbna.cbv:+Result:+26++Output Entity: standard-out+7,5,3,1,2,4,2,3,1,2,6,4,2,3,1,2,5,3,1,2,4,2,3,1,2,7,5,3,1,2,4,2,3,1,2,6,4,2,3,1,2,5,3,1,2,4,2,3,1,2+programs/comparison2a.cbv:+Result:+28++Output Entity: standard-out+3,3,3,3,4,4,4,4+programs/basics4.cbv:+Result:+7+programs/app1.cbv:+Result:+4+programs/fib-clash-cbna2.cbv:+Result:+26++Output Entity: standard-out+7,5,3,1,2,4,2,3,1,2,6,4,2,3,1,2,5,3,1,2,4,2,3,1,2,7,5,3,1,2,4,2,3,1,2,6,4,2,3,1,2,5,3,1,2,4,2,3,1,2+programs/mp5.cbv:+Result:+astv(give,astv(give,astv(structural-assigned,astv(bound-value,astv(algebraic-datatypes,"plus"))),astv(apply,astv(given),astv(tuple,astv(give,astv(give,astv(structural-assigned,astv(bound-value,astv(algebraic-datatypes,"plus"))),astv(apply,astv(given),astv(tuple,astv(give,astv(give,astv(structural-assigned,astv(bound-value,astv(algebraic-datatypes,"plus"))),astv(apply,astv(given),astv(tuple,astv(naturals,1),astv(given)))),astv(apply,astv(given),astv(tuple,astv(structural-assigned,astv(bound-value,astv(algebraic-datatypes,"x"))),astv(given)))),astv(given)))),astv(apply,astv(given),astv(tuple,astv(structural-assigned,astv(bound-value,astv(algebraic-datatypes,"x"))),astv(given)))),astv(given)))),astv(apply,astv(given),astv(tuple,astv(structural-assigned,astv(bound-value,astv(algebraic-datatypes,"x"))),astv(given))))+programs/ast-lam.cbv:+Result:+42+programs/mp2.cbv:+Result:+astv(give,astv(give,astv(structural-assigned,astv(bound-value,astv(algebraic-datatypes,"plus"))),astv(apply,astv(given),astv(tuple,astv(naturals,3),astv(given)))),astv(apply,astv(given),astv(tuple,astv(naturals,2),astv(given))))+programs/ast-from-downml2.cbv:+Result:+7+programs/ast-let-product-dynamic.cbv:+Result:+15+programs/comparison2b.cbv:+Result:+24++Output Entity: standard-out+3,3+programs/let-product-dynamic.cbv:+Result:+15+programs/basics3.cbv:+Result:+6+programs/fib-const-cbna.cbv:+Result:+42+programs/app3.cbv:+Result:+42+programs/fib-double-cbv.cbv:+Result:+26++Output Entity: standard-out+7,5,3,1,2,4,2,3,1,2,6,4,2,3,1,2,5,3,1,2,4,2,3,1,2+programs/fib-const-cbv.cbv:+Result:+42++Output Entity: standard-out+7,5,3,1,2,4,2,3,1,2,6,4,2,3,1,2,5,3,1,2,4,2,3,1,2+programs/ast-app2.cbv:+Result:+7+programs/ast-let-product-static.cbv:+Result:+15+programs/fib-clash2-cbna.cbv:+Result:+13++Output Entity: standard-out+7,5,3,1,2,4,2,3,1,2,6,4,2,3,1,2,5,3,1,2,4,2,3,1,2+programs/comparison1a.cbv:+Result:+14++Output Entity: standard-out+2,1,0,3,2,1,0+programs/letdown1.cbv:+Result:+astv(asts,astv(naturals,2))+programs/fib-double-cbna.cbv:+Result:+26++Output Entity: standard-out+7,5,3,1,2,4,2,3,1,2,6,4,2,3,1,2,5,3,1,2,4,2,3,1,2,7,5,3,1,2,4,2,3,1,2,6,4,2,3,1,2,5,3,1,2,4,2,3,1,2+programs/curry.cbv:+Result:+5+programs/app2.cbv:+Result:+7+programs/basics1.cbv:+Result:+3+programs/mp1.cbv:+Result:+astv(naturals,7)++Output Entity: standard-out+2
funcons-lambda-cbv-mp.cabal view
@@ -2,9 +2,10 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                funcons-lambda-cbv-mp-version:             0.1.0.0-synopsis:            Basic call-by-value lambda-calculus with operational semantics based on Funcons--- description:         +version:             0.1.0.2+synopsis:            call-by-value lambda-calculus with meta-programming+description:         Basic call-by-value lambda-calculus with operational semantics based on Funcons and meta-programming extensions+ license:             BSD3 license-file:        LICENSE author:              L. Thomas van Binsbergen@@ -13,6 +14,10 @@ category:            Language build-type:          Simple extra-source-files:  ChangeLog.md+                      programs/*.cbv+                      run-tests.sh+                      full.output+                      README.txt cabal-version:       >=1.10  executable lambda-cbv@@ -21,7 +26,7 @@   -- other-extensions:       build-depends:        base >=4.9 && <= 5.0                       , gll >= 0.4.0.3-                      , funcons-tools >= 0.2.0.1+                      , funcons-tools >= 0.2.0.5                       , containers >= 0.5.7                       , text >= 1.2.2   hs-source-dirs:      src
+ programs/app1.cbv view
@@ -0,0 +1,3 @@++let plus1 = \x. 1+x+in plus1 3
+ programs/app2.cbv view
@@ -0,0 +1,3 @@++let plus1 = \x. 1+x+in plus1 3 + plus1 2
+ programs/app3.cbv view
@@ -0,0 +1,5 @@++let mult = \y. \x. if x <= 0 then 0+                             else y + this (x + -1)+in let plus1 = \x. 1+x+   in mult (plus1 3 + plus1 2) 6
+ programs/ast-app.cbv view
@@ -0,0 +1,4 @@++let plus3 = App (Bound "plus") (lift 3)+ in eval(plus3) 4+
+ programs/ast-app2.cbv view
@@ -0,0 +1,3 @@++let seven = App (App (Bound "plus") (lift 3)) (lift 4)+ in eval(seven)
+ programs/ast-from-downml.cbv view
@@ -0,0 +1,2 @@++Plus $([|[|3|]|]) [| 4 |]
+ programs/ast-from-downml2.cbv view
@@ -0,0 +1,2 @@++$(Plus $([|[|3|]|]) [| 4 |])
+ programs/ast-lam.cbv view
@@ -0,0 +1,3 @@++letdown astlam = Lam (Bind "x") (Bound "x")+ in $(astlam) 42
+ programs/ast-let-product-dynamic.cbv view
@@ -0,0 +1,7 @@++let gen = \n. if n <= 0 then lift 0 +                        else Plus (Bound "x") (this (n + -1))+in let product = \n. Lam (Bind "x") (gen n )+   in let triple = eval( product 3 )+      in triple 5+
+ programs/ast-let-product-static.cbv view
@@ -0,0 +1,6 @@++letdown gen = \n. if n <= 0 then lift 0 +                            else Plus (Bound "x") (this (n + -1))+in letdown product = \n. Lam (Bind "x") (gen n )+   in $(product 3) 5+
+ programs/ast-output.cbv view
@@ -0,0 +1,2 @@++eval(Output (lift 3))
+ programs/basics1.cbv view
@@ -0,0 +1,2 @@+let x = 3+in x
+ programs/basics2.cbv view
@@ -0,0 +1,1 @@+3 + 2 // 3+2 is lexed as 2 integers (`3` and `+2`)
+ programs/basics3.cbv view
@@ -0,0 +1,2 @@+let x = 3 + 2 +in x + 1
+ programs/basics4.cbv view
@@ -0,0 +1,1 @@+(\x. x) 7
+ programs/comparison1a.cbv view
@@ -0,0 +1,7 @@++let gen = \y. \x. if x <= 0 then 0+                            else y + this (output (x + -1))+in let double = gen 2+   in double 3 + double 4 // prints 2, 1, 0, 3, 2, 1, 0++
+ programs/comparison1b.cbv view
@@ -0,0 +1,7 @@++let gen = \x. if x <= 0 then lift 0+                        else [| y + $(this (output (x + -1))) |]+in let double = \y. eval(gen 2)+   in double 3 + double 4 // prints 1, 0, 1, 0++
+ programs/comparison1c.cbv view
@@ -0,0 +1,8 @@++let gen = \x. if x <= 0 then lift 0+                        else App (App (Bound "plus") (Bound "y")) (this (output (x + -1)))+in let code = gen 2+   in let double = \y. eval(code)+      in double 3 + double 4 // prints 1, 0++
+ programs/comparison2a.cbv view
@@ -0,0 +1,8 @@++let gen = \x. if x <= 0 then lift 0+                        else [| (output y) + $(this (x + -1)) |]+in let code = gen 2+   in let quadruple = \y. (eval(code) + eval(code))+      in quadruple 3 + quadruple 4 // prints 3,3,3,3, 4,4,4,4++
+ programs/comparison2b.cbv view
@@ -0,0 +1,8 @@++let gen = \x. if x <= 0 then lift 0+                        else [| (output y) + $(this (x + -1)) |]+in let code = gen 2+   in let quadruple = \y. (!code + eval(code))+      in quadruple 3 + quadruple 4 // prints 3,3 and yields 24 (4 too ++
+ programs/ct-eval.cbv view
@@ -0,0 +1,3 @@++letdown x = lift 0+in $(x)
+ programs/curry.cbv view
@@ -0,0 +1,3 @@++let f = \x. \y. x + y+ in f 2 3
+ programs/fib-clash-cbna.cbv view
@@ -0,0 +1,7 @@++let fib = \n. if (output n) <= 2 +                then 1+                else this (n + -2) + this (n + -1)+in let double = \a. eval(a) + eval(a)+   in double [| fib 7 |] +                               
+ programs/fib-clash-cbna2.cbv view
@@ -0,0 +1,10 @@++let fib = \n. if (output n) <= 2 +                then 1+                else this (n + -2) + this (n + -1)+in let double = \fib. eval(fib) + eval(fib)+   in double [| $(lift fib) 7 |] +// dereferences outer `fib` once, as part of application of `double`+// applies the resulting lambda twice, thus computing the 7th fib number twice+// can be solved by replacing first inner $fib by !fib+                               
+ programs/fib-clash2-cbna.cbv view
@@ -0,0 +1,7 @@++let fib = \n. if (output n) <= 2 +                then 1+                else this (n + -2) + this (n + -1)+in let double = \n. eval(n) + (let fib = \x. 0 in eval(n))+   in double [| fib 7 |] // computes 7th fibno once, snd eval(n) gives 0, yields 13+                               
+ programs/fib-clash2-cbna2.cbv view
@@ -0,0 +1,7 @@++let fib = \n. if (output n) <= 2 +                then 1+                else this (n + -2) + this (n + -1)+in let double = \n. eval(n) + (let fib = \x. 0 in eval(n))+   in double [| $(lift fib) 7 |] // computes 7th fibno twice, yields 26+                               
+ programs/fib-clash2-cbne.cbv view
@@ -0,0 +1,7 @@++let fib = \n. if (output n) <= 2 +                then 1+                else this (n + -2) + this (n + -1)+in let double = \n. !n + (let fib = \x. 0 in eval(n))+   in double [| fib 7 |] // computes 7th fibno once, snd eval(n) gives 13, yields 26+                               
+ programs/fib-const-cbna.cbv view
@@ -0,0 +1,7 @@++let fib = \n. if (output n) <= 2 +                then 1+                else this (n + -2) + this (n + -1)+in let const = \n. \k. eval n+   in const [|42|] [|fib 7|]+                               
+ programs/fib-const-cbne.cbv view
@@ -0,0 +1,7 @@++let fib = \n. if (output n) <= 2 +                then 1+                else this (n + -2) + this (n + -1)+in let const = \n. \k. !n+   in const [|42|] [|fib 7|]+                               
+ programs/fib-const-cbv.cbv view
@@ -0,0 +1,7 @@++let fib = \n. if (output n) <= 2 +                then 1+                else this (n + -2) + this (n + -1)+in let const = \n. \k. n+   in const 42 (fib 7)+                               
+ programs/fib-double-cbna.cbv view
@@ -0,0 +1,7 @@++let fib = \n. if (output n) <= 2 +                then 1+                else this (n + -2) + this (n + -1)+in let double = \n. eval(n) + eval(n) //equivalent to \n. (fib 7) (fib 7) when run+   in double [| fib 7 |]+                               
+ programs/fib-double-cbne.cbv view
@@ -0,0 +1,7 @@++let fib = \n. if (output n) <= 2 +                then 1+                else this (n + -2) + this (n + -1)+in let double = \n. !n + eval(n) //equivalent to \n. (fib 7) (fib 7) when run+   in double [| fib 7 |]+                               
+ programs/fib-double-cbv.cbv view
@@ -0,0 +1,7 @@++let fib = \n. if (output n) <= 2 +                then 1+                else this (n + -2) + this (n + -1)+in let double = \n. n + n+   in double (fib 7)+                               
+ programs/fib-double-cbv2.cbv view
@@ -0,0 +1,7 @@++let fib = \n. if (output n) <= 2 +                then 1+                else this (n + -2) + this (n + -1)+in let double = \n. 13 + 13+   in double (fib 7)+                               
+ programs/let-product-dynamic.cbv view
@@ -0,0 +1,5 @@++let gen = \n. if n <= 0 then [|0|] else [| x + $(this (n + -1)) |]+in let product = \n. [| \x. $( gen n ) |]+   in (eval (product 3)) 5+
+ programs/letdown-product-static.cbv view
@@ -0,0 +1,5 @@++letdown gen = \n. if n <= 0 then [|0|] else [| x + $(this (n + -1)) |]+in letdown product = \n. [| \x. $( gen n ) |]+   in $( product 3 ) 8 +
+ programs/letdown1.cbv view
@@ -0,0 +1,3 @@++letdown f = \x.lift x+in $(f (f (f 2)))
+ programs/mp1.cbv view
@@ -0,0 +1,2 @@++lift(output 2 + 5)
+ programs/mp2.cbv view
@@ -0,0 +1,2 @@++[| 3 + 2 |]
+ programs/mp3.cbv view
@@ -0,0 +1,2 @@++output ($([| 3 + 2 |]))
+ programs/mp4.cbv view
@@ -0,0 +1,4 @@++let code = [| 3 + x |]+in let x = 7+    in eval(code)
+ programs/mp5.cbv view
@@ -0,0 +1,4 @@++let code = \y. if y <= 0 then lift 1+                         else [| $(this (y + -1)) + x |]+in code 3
+ programs/mp6.cbv view
@@ -0,0 +1,5 @@++letdown code = \y. if y <= 0 then [| 0 |]+                             else [| x + $(this (y + -1)) |]+in let x = 7 +   in $(code 6)
+ run-tests.sh view
@@ -0,0 +1,11 @@+#!/bin/bash++run_test() {+  echo $1:;+  out=$(dist/build/lambda-cbv/lambda-cbv $1 --refocus);+  if [[ $out ]]+    then  echo "$out";+  fi+}+export -f run_test+find programs -name "*.cbv" | xargs -n1 -I{} bash -c 'run_test "$@"' _ {}