Re: [Haskell-cafe] Re: Is it possible to read existential types?

2004-04-29 Thread Chung-chieh Shan
On 2004-04-28T15:12:03-0400, S. Alexander Jacobson wrote: Ok, but it sounds like you need to know the list of possible types in advance. Is it possible to have a lib take a filepath and type name as an arbitrary string, and read the instance in? I don't think you need to know the list of

Re: [Haskell-cafe] Re: Is it possible to read existential types?

2004-04-29 Thread Chung-chieh Shan
On 2004-04-28T23:33:31-0400, S. Alexander Jacobson wrote: I don't think this works. I just tried it with: main = print $ lookupRead 1 [(1,(Integer,100))] This fails for the same reason print $ read 100 fails. You need to give a type signature to avoid type-class instance ambiguity:

Re: [Haskell-cafe] Re: Is it possible to read existential types?

2004-04-29 Thread S. Alexander Jacobson
I don't think this works. I just tried it with: main = print $ lookupRead 1 [(1,(Integer,100))] How would Haskell know that typ actually does equal typeOf? -Alex- _ S. Alexander Jacobson mailto:[EMAIL

Re: [Haskell-cafe] Re: Is it possible to read existential types?

2004-04-29 Thread S. Alexander Jacobson
But isn't the point of this code that you don't need that type signature? If I knew in advance that it was an Integer then I wouldn't need to passs Integer in the list. -Alex- On Thu, 29 Apr 2004, Chung-chieh Shan wrote: On 2004-04-28T23:33:31-0400, S. Alexander Jacobson wrote: I don't

Re: [Haskell-cafe] Re: Is it possible to read existential types?

2004-04-29 Thread Chung-chieh Shan
On 2004-04-29T11:50:48-0400, S. Alexander Jacobson wrote: But isn't the point of this code that you don't need that type signature? If I knew in advance that it was an Integer then I wouldn't need to passs Integer in the list. In the context in which the code was originally written, the

[Haskell-cafe] Dynamics/Read and Existential types (was: Is it possible to read existential types?)

2004-04-29 Thread S. Alexander Jacobson
So let me ask this question a different way. Is it possible to use Read/Show or Typeable with Existential types. Given MyClass and MyType as follows: class (Read a,Show a,Typeable)=MyClass a where foo::a type MyType = forall a. MyClass a= [a] Is there a way to persist MyType? My