[Haskell-cafe] Fwd: Questions about lambda calculus

namekuseijin namekuseijin at gmail.com
Wed Nov 10 12:44:37 EST 2010


On Wed, Nov 10, 2010 at 3:36 PM, Ryan Ingram <ryani.spam at gmail.com> wrote:
> Max has a good solution, but another solution is to embed an untyped
> lambda calculus into Haskell
>
> -- "atom" is just used for output during testing
> data U = Atom Int | F (U -> U)
>
> instance Show U where
>   show (Atom s) = s
>   show (F _) = "<function>"
>
> -- function application
> F f $$ x = f x
> infixl 9 $$
>
> fTrue = F $ \x -> F $ \y -> x
> fFalse = F $ \x -> F $ \y -> y
>
> fIf = F $ \b -> F $ \x -> F $ \y -> b $$ x $$ y

this also has the "benefit" of looking as perlish as the original
example, if you know what I mean... ;)


More information about the Haskell-Cafe mailing list