Support for list literals in Lambdas
This commit is contained in:
parent
f9864b8361
commit
f4e50353ed
@ -75,6 +75,9 @@ elimLambda = go
|
|||||||
go (SLambda [f] (SLambda [g] (SLambda [x] body)))
|
go (SLambda [f] (SLambda [g] (SLambda [x] body)))
|
||||||
| body == SApp (SVar f) (SApp (SVar g) (SVar x)) = _B
|
| body == SApp (SVar f) (SApp (SVar g) (SVar x)) = _B
|
||||||
-- General elimination
|
-- General elimination
|
||||||
|
go (SLambda [v] (SList xs))
|
||||||
|
= elimLambda (SLambda [v] (foldr wrapTLeaf TLeaf xs))
|
||||||
|
where wrapTLeaf m r = SApp (SApp TLeaf m) r
|
||||||
go (SLambda (v:vs) body)
|
go (SLambda (v:vs) body)
|
||||||
| null vs = toSKI v (elimLambda body)
|
| null vs = toSKI v (elimLambda body)
|
||||||
| otherwise = elimLambda (SLambda [v] (SLambda vs body))
|
| otherwise = elimLambda (SLambda [v] (SLambda vs body))
|
||||||
|
@ -341,6 +341,10 @@ lambdas = testGroup "Lambda Evaluation Tests"
|
|||||||
, testCase "Lambda with a list literal" $ do
|
, testCase "Lambda with a list literal" $ do
|
||||||
let input = "f = (\\x : x)\nf [t (t t)]"
|
let input = "f = (\\x : x)\nf [t (t t)]"
|
||||||
runTricu input @?= "Fork Leaf (Fork (Stem Leaf) Leaf)"
|
runTricu input @?= "Fork Leaf (Fork (Stem Leaf) Leaf)"
|
||||||
|
|
||||||
|
, testCase "Lambda with list literal" $ do
|
||||||
|
let input = "(\\a : [(a)]) 1"
|
||||||
|
runTricu input @?= "Fork (Fork (Stem Leaf) Leaf) Leaf"
|
||||||
]
|
]
|
||||||
|
|
||||||
providedLibraries :: TestTree
|
providedLibraries :: TestTree
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
cabal-version: 1.12
|
cabal-version: 1.12
|
||||||
|
|
||||||
name: tricu
|
name: tricu
|
||||||
version: 0.15.0
|
version: 0.16.0
|
||||||
description: A micro-language for exploring Tree Calculus
|
description: A micro-language for exploring Tree Calculus
|
||||||
author: James Eversole
|
author: James Eversole
|
||||||
maintainer: james@eversole.co
|
maintainer: james@eversole.co
|
||||||
|
Loading…
x
Reference in New Issue
Block a user