An implementation of bird forest inspired from To mock a mocking bird.
A lambda calculus and combinatory logic interpreter.
As for now, you can call out the following birds
- I : Idiot
- S : Starling
- K : Kestrel
- B : Bluebird
- C : Cardinal
Most of the birds could be found in the forest, although they are unnamed. Some birds might not terminate, for example, the Y-combinator bird (S(CB(SII))(CB(SII))).
The REPL can parse mentioned birds and lambda expression using the de bruijn index notation.
SKKwill be parsed as(SK)Kand returnIλ[0]meansλx.xλλλ[0][1]meansλxyz.zy
- download haskell and cabal
cabal run birdForestto open a repl
- run
cabal testto run the test
All library files are in /src/, tests are in /test/ and repl is in /app/
- Implemented parsing certain birds listed above
- Parsing detail specified in
Expr.hs - Parsing algorithm in
Parser.hs
- splited into intepret, (re)sugar
- intepretation break down each bird into the equivalent lambda expression with de bruijn index
- interpretation takes care of reductions and result in a non-reducible lambda expression
- encyclopedia map back the expression to its name
- ie. map
λx.xorλ0toI - ie. map
λxy.xorλλ1toK
- ie. map
- prettify by changing de bruijn index notation into named lambda
Expr is a type that represent the syntax of the language.
Result is a type of Either String Expr where the string is the error message
parseExpr :: String -> Result- parse string into a
Result
- parse string into a
interp :: Expr -> Result- makes reduction of any Expression containing
SandK
- makes reduction of any Expression containing
evaluate :: String -> Result- parse the string, and do
interp.
- parse the string, and do
encyclopedia :: Expr -> String- yields the prettiest response with bird name and named lambda expression
prettify :: Expr -> String- returns the corresponding named lambda expression
show :: Expr -> String- returns the lambda expression in de bruijn index style