On Wed, Nov 10, 2010 at 3:36 PM, Ryan Ingram <ryani.s...@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... ;)
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to