Existential types: want better syntactic support (autoboxing?)

Bulat Ziganshin bulatz at HotPOP.com
Mon Jan 30 16:31:19 EST 2006


Hello Duncan,

Monday, January 30, 2006, 9:02:48 PM, you wrote:

DC> class IStream s where
DC>   readBlock :: s -> IO Block

DC> data IStream = IStream {
DC>   istream_readBlock :: IO Block
DC> }

DC> instance IStream IStream where
DC>   readBlock s = istream_readBlock s

DC> abstractIStream :: IStream s => s -> IStream
DC> abstractIStream s = IStream { istream_readBlock = readBlock s }


how that is done in my lib:

class (Monad m) => Stream m h | h->m where
    vClose :: h -> m ()
    vIsEOF :: h -> m Bool
    .....

data Handle = forall h . (Stream IO h) => Handle h

instance Stream IO Handle where
    vClose        (Handle h) = vClose        h
    vIsEOF        (Handle h) = vIsEOF        h
    .....




-- 
Best regards,
 Bulat                            mailto:bulatz at HotPOP.com





More information about the Haskell-prime mailing list