[Haskell-cafe] Re: Help understanding type error

Dominic Steinitz dominic.steinitz at blueyonder.co.uk
Fri Sep 7 03:15:21 EDT 2007


Matthew Brecknell <haskell <at> brecknell.org> writes:

> 
> Levi Stephen:
> > I have a data type:
> > 
> > > data T a = forall b. (Show b) => T b a
> > 
> > and I want to use/extract 'b' from this.
> 
> You can't. (Well, I believe you can if you have prior knowledge of the
> actual type of the existentially wrapped "b", and you're willing to use
> an "unsafe" coerce, but I've never tried.)
> 
You can do type safe casts. IIRC Stephanie Weirich presented a paper on it at 
icfp 2000(?). Of course, as you point out, you would still need prior 
knowledge of the type.



More information about the Haskell-Cafe mailing list