lambda calculus - Haskell AST with recursive types -
i'm trying build lambda calculus solver, , i'm having slight problem constructing ast. lambda calculus term inductively defined as:
1) variable
2) lambda, variable, dot, , lambda expression.
3) bracket, lambda expression, lambda expression , bracket.
what (and @ first tried) this:
data expr = variable | abstract variable expr | application expr expr now doesn't work, since variable not type, , abstract variable expr expects types. hacky solution have:
type variable = string data expr = atomic variable | abstract variable expr | application expr expr now annoying since don't atomic variable on own, abstract taking string rather expr. there way can make more elegant, , first solution?
your first solution erroneous definition without meaning. variable not type there, it's nullary value constructor. can't refer variable in type definition can't refer value, true, false or 100.
the second solution in fact direct translation of write in bnf:
var ::= <string> term ::= λ <var>. <term> | <term> <term> | <var> and there nothing wrong it.
Comments
Post a Comment