[Haskell-cafe] Constructing a datatype given just its constructor as a string?

Donald Bruce Stewart dons at cse.unsw.edu.au
Sun Jun 24 21:45:32 EDT 2007

>    Just noticed that all my responses have been going only to
>    Neil, not  to the group.
>    Anyway, the jist of our conversation was that it's not
>    possible to create arbitrary datatypes/constructors from
>    strings in Haskell.  Can anyone deny/confirm?

Entirely possible. Though it would be interesting to see the code that
is to process the arbitrary types as they arrive, after deserialising.

Anyway there was a thread on this last week. One solution is to have a
symbol table mapping type reps to values of a given type, then you use
that to know which type to read from the constructor tag, resolving the
problem of not knowing what type you're reading.

-- Don

More information about the Haskell-Cafe mailing list