parsing, update readme
This commit is contained in:
parent
098cf0832a
commit
f64bf8be2b
3 changed files with 43 additions and 33 deletions
|
|
@ -9,39 +9,37 @@ spec = do
|
|||
it "can parse variable" $
|
||||
(parse "x") `shouldBe` Right (Variable "x")
|
||||
it "can parse identity abstraction" $
|
||||
(parse "λx.x") `shouldBe` Right (Abstraction ("x", Variable "x"))
|
||||
(parse "λx.x") `shouldBe` Right (Abstraction "x" (Variable "x"))
|
||||
it "can parse mockingbird of identity" $
|
||||
(parse "(λx.x x) (λx.x)") -- (λx.x) (λx.x) -> (λx.x)
|
||||
`shouldBe` Right
|
||||
( Application
|
||||
( Abstraction
|
||||
( "x",
|
||||
Application
|
||||
( Variable "x",
|
||||
Variable "x"
|
||||
)
|
||||
),
|
||||
Abstraction ("x", Variable "x")
|
||||
"x"
|
||||
( Application
|
||||
(Variable "x")
|
||||
(Variable "x")
|
||||
)
|
||||
)
|
||||
(Abstraction "x" (Variable "x"))
|
||||
)
|
||||
it "it can parse successor" $
|
||||
(parse "λn.λf.λx.f (n f x)")
|
||||
`shouldBe` Right
|
||||
( Abstraction
|
||||
( "n",
|
||||
Abstraction
|
||||
( "f",
|
||||
Abstraction
|
||||
( "x",
|
||||
Application
|
||||
( Variable "f",
|
||||
Application
|
||||
"n"
|
||||
( Abstraction
|
||||
"f"
|
||||
( Abstraction
|
||||
"x"
|
||||
( Application
|
||||
(Variable "f")
|
||||
( Application
|
||||
( Application
|
||||
( Variable "n",
|
||||
Variable "f"
|
||||
),
|
||||
Variable "x"
|
||||
(Variable "n")
|
||||
(Variable "f")
|
||||
)
|
||||
(Variable "x")
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue