[Haskell-cafe] Reading open data types

Benja Fallenstein benja.fallenstein at gmail.com
Wed Jun 13 15:20:07 EDT 2007

Hi Bulat,

2007/6/13, Bulat Ziganshin <bulat.ziganshin at gmail.com>:
> > We've had a discussion on #haskell about how we can make a function
> > that reads in serialized values of an open data type, such as
> look at Data.Generics.Text which may be implements exactly what you
> need

Unfortunately not. Data.Generics.Text provides

gread :: Data a => ReadS a

That is, you have to constrain its return type to the particular type
you want to read. What I'm looking for is a way to read any type
implementing a certain class (deciding the type to use based on a type
tag) and returning the result in an existential wrapper.

- Benja

More information about the Haskell-Cafe mailing list