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

2004-04-26 Thread S. Alexander Jacobson
Is is possible to read/show an existentially typed
list?

Would it be possible if, instead of using
read/show, I defined some variant that relies on
the typeof/typeable infrastructure?  Is there a
way to read in a typename for use in coercing a
read?

-Alex-

_
S. Alexander Jacobson  mailto:[EMAIL PROTECTED]
tel:917-770-6565   http://alexjacobson.com
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe


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

2004-04-26 Thread Chung-chieh Shan
S. Alexander Jacobson [EMAIL PROTECTED] wrote in article [EMAIL PROTECTED] in 
gmane.comp.lang.haskell.cafe:
 Is is possible to read/show an existentially typed
 list?
 
 Would it be possible if, instead of using
 read/show, I defined some variant that relies on
 the typeof/typeable infrastructure?  Is there a
 way to read in a typename for use in coercing a
 read?

Dylan Thurston and I encountered this problem a while ago.  Show is
easy: just use a type like exists a. Show a =   Read is hard,
because one needs to get the Read dictionary from somewhere, and
the dynamic typing facility in Haskell does not include type-class
constraint reduction at runtime.  The best solution we came up with was
to replace the existentially typed list with a list of string-string
pairs, where the first string names the type and the second string names
the value.  The call to read is only done at lookup time, not at
file-reading time.

-- 
Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig
Be it declared and enacted by this present Parliament / That the People
of England / are / a Commonwealth and free State / without any King or
House of Lords.-- An Act declaring England to be a Commonwealth
1649-05-19 | 355 years | 2004-05-19http://tinyurl.com/2dqnh

___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Data constructors

2004-04-26 Thread Iavor S. Diatchki
hi,
i have thought about things like that, but the qualification 
Type.Constructor does
not seem particularly useful.  you can achieve the same by using _, e.g
data A = A_X | A_Y
data B = B_X | B_Y
alternatively (at least for non-recursilve datatypes) anonymous sums 
(ala TREX's records)
could work pretty well, but they are not in Haskell.  details about 
those can probably be
found in Ben Gaster's thesis.
-iavor

Mark Carroll wrote:

I keep running into annoyance in having to name data constructors
differently if they're for different types if they're in the same module
or something. I wish that something like some Type.Constructor syntax
worked in order to disambiguate. Or, better still, I have that problem
with function names too (e.g. Data.List.union, Data.Set.union, IIRC) and
it occurs to me that a lot of this can be resolved automatically because
the types only make sense with one of the choices.
I'm not really proposing any changes; more, I'm wondering what others'
thinking is about this sort of thing - what annoys them, how they get
around it, etc.
-- Mark
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe
 

___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe