Loup Vaillant wrote:
-> support algebraic data types and case expressions (unless I can get
away with encoding them as functions),
Which you always can,
data Foo = A a1...an | B b1...bn |...
==
type Foo :: forall r.
(a1->...->an -> r) ->
(b1->...->bn -> r) ->...
-> r
A a1...an = \fa _... -> fa a1...an
B b1...bn = \_ fb... -> fb b1...bn
...
The only trick is that you need to have closures (in order to build the
Foos) and you need to have first-class functions (in order to pass the
destructors in). If you're familiar with the STG machine, this is what
they do under the covers anyways. At the core level, all you need is
some primitive to force evaluation.
(Church Encoding)++
--
Live well,
~wren
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe