[Haskell-cafe] Client-extensible heterogeneous types
Jacek Generowicz
Jacek.Generowicz at cern.ch
Tue Oct 12 09:08:30 EDT 2010
[Sorry Stephen, didn't mean to take this off-list, hence the resend.]
On 2010 Oct 12, at 14:31, Stephen Tetley wrote:
> To do this I would use dynamic types (via Data.Dynamic).
Ah, yes, I've just stumbled upon these while trying to figure out what
APPLY or FUNCALL would mean in Haskell.
> There are more typeful ways to deal with heterogeneous structures[*],
> but if "clients can easily extend it with their own new types" you've
> pretty much defined what dynamic types solve.
Cool.
I've just started experimenting with implementing the dynamism by
holding functions (methods) alongside data in a variant type. I think
I'll see what I learn by taking this a bit further, before digging
into Data.Dynamic, but it's good to know there is some prior art to
turn to in the long run.
Many thanks.
Reading the GHC docs on Data.Dynamic, I infer that Data.Dynamic is non-
standard, but, in principle, portable to other implementations.
Is that understanding correct?
> [*] See the HList papers and library and various solutions to the
> "expression problem".
This seems to be extremely relevant too, though I think that I'll
stick to my own experiment and Data.Dynamic to start with.
Thanks very much.
More information about the Haskell-Cafe
mailing list