"Duplicate instance declarations"
Bulat Ziganshin <[email protected]> Mon, 26 Dec 2005 01:20:45 +0300
| Newsgroups | gmane.comp.lang.haskell.glasgow.user,gmane.comp.lang.haskell.hugs.user |
|---|---|
| Message-ID | <[email protected]> |
Hello all
why the folowing is not allowed even with all extensions enabled both
in Hugs and GHC?
class BufStream h where
class CharStream h where
instance (CharStream h) => BufStream h where
class MemoryStream h where
instance (MemoryStream h) => BufStream h where
i plan to implement many streams, some of which are supporting
getBuf/putBuf interface of MemoryStream, and some getChar/putChar
interface of CharStream and then automatically derive BufStream using
the appropriate operations. but that just fail
how can i pass around these restriction?
can this be supported in future Hugs/GHC versions?
... just now i encountered this problem again:
-- Copy entire contents of Stream to another Stream
class (Stream h1, Stream h2) => StreamCopying h1 h2 where
copyStream :: h1 -> h2 -> IO ()
instance (MemoryStream h1, BufStream h2) => StreamCopying h1 h2 where
copyStream h1 h2 = return ()
instance (BufStream h1, MemoryStream h2) => StreamCopying h1 h2 where
copyStream h1 h2 = return ()
--
Best regards,
Bulat mailto:[email protected]