项目作者: d-dorazio

项目描述 :
Lambda Calculus. All you need is a lambda.
高级语言: Haskell
项目地址: git://github.com/d-dorazio/lc.git
创建时间: 2017-04-17T19:17:07Z
项目社区:https://github.com/d-dorazio/lc

开源协议:Other

下载


All you need is a lambda

Little experiments with lambda
calculus
. As of now there are
two different implementations of lambda calculus. There is a vanilla one that is
just a straight implementation of lambda calculus as descibed by Alonzo
Church
. On top of that there is an
“Enhanced” lambda calculus that also supports let statements.

Also, there are two interpreters(a.k.a reducers): deBruijnInterpreter that
uses De Bruijn Index and
therefore is strict in the sense that all the referenced variables must be in
scope before referencing them. The second one is dynamicInterpreter that
allows to reference not yet defined variables.

For example (λfoo. (foo x) b)(λx y. y (x x)) will reduce to x (b b) if using
deBruijnInterpreter, but it will reduce to b (b b) when using
dynamicInterpreter.

Quickstart

Be sure to have stack installed.

  1. $ stack build
  2. $ stack exec lc
  3. λ >> λx.x
  4. λx.x
  5. λ >> x.x) a
  6. a
  7. λ >> mytrue = \x y. x
  8. λxy.x
  9. λ >> myfalse = \x y. y
  10. λxy.x
  11. λ >> true
  12. λxy.x
  13. λ >> false
  14. λxy.y
  15. λ >> true t f
  16. t
  17. λ >> false t f
  18. f
  19. λ >> (not true) t f
  20. f
  21. λ >> 0
  22. λfx.x
  23. λ >> 0 f x
  24. x
  25. λ >> (succ 0) f x
  26. f x

Stdlib

The repl also provides a limited form of standard library. Here are some bindings:

Feel free to grep for stdLib in app/Main.hs though :wink:.