[Haskell-cafe] Embedded Functions in Algebraic Data Types?
Chaddaï Fouché
chaddai.fouche at gmail.com
Sun Feb 10 08:42:36 EST 2008
2008/2/10, Michael Feathers <mfeathers at mindspring.com>:
> On a lark, I loaded this into Hugs this morning, and it didn't complain:
>
>
> data Thing = Thing (Integer -> Integer)
>
>
>
> But, I've never seen that sort of construct in an example. Do people
> ever embed functions in ADTs?
Yes, anyway you can embed function in Maybe a or Either a b for
example, since they're polymorphic. Embedding functions in ADT
purposefully happens quite often too, just look at the State Monad,
the functionnal references proposal and so on...
Recently I embedded functions into a denotational semantic ADT for a
tiny DSL, there's plenty of use cases.
--
Jedaï
More information about the Haskell-Cafe
mailing list