[Haskell-cafe] Re: [Haskell] ANN: IOSpec 0.1

Wouter Swierstra wss at Cs.Nott.AC.UK
Wed Apr 25 06:01:55 EDT 2007


Hi Twan,

> Wouter Swierstra wrote:
>>             Test.IOSpec    Version 1.0
> Shouldn't that be 0.1?

You're right of course.

> You use Dynamic for the data type in IORefs, this has the  
> unfortunate consequence of needing Typeable constraints. You could  
> try to use unsafeCoerce instead,
> > type Data = ()
> > unsafeToData :: a -> Data
> > unsafeToData = unsafeCoerce
> > unsafeFromData :: Data -> a
> > unsafeFromData = unsafeCoerce
>
> I think this should be just as safe as Dynamic, since internally  
> Dynamic uses unsafeCoerce as well. Just steal the details from there.

I'm not entirely happy with the "unsafeFromDynamic" approach I use at  
the moment. GHC can derive instances of Typeable, so the price you  
have to pay is not too high. The real problem is that Haskell's type  
system is not expressive enough to cleanly describe the type of the  
heap (I know, I could be using HList, but still...).

If you're interested, I also have a dependently typed version of the  
code for IORefs that allows heterogeneous, type-safe, well-scoped  
pointers. I should probably mention that an ulterior motive for this  
work is integrating IO in dependently typed languages such as  
Epigram. It is all, of course, still very much subject to active  
research.

   Wouter




This message has been checked for viruses but the contents of an attachment
may still contain software viruses, which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.



More information about the Haskell-Cafe mailing list