Some more Typeable instances, as requested on the ghc-users list a while back.
import System.IO.Unsafe ( unsafeInterleaveIO )
import Control.Concurrent.MVar
+import Data.Typeable
+
+#include "Typeable.h"
-- A channel is represented by two @MVar@s keeping track of the two ends
-- of the channel contents,i.e., the read- and write ends. Empty @MVar@s
= Chan (MVar (Stream a))
(MVar (Stream a))
+INSTANCE_TYPEABLE1(Chan,chanTc,"Chan")
+
type Stream a = MVar (ChItem a)
data ChItem a = ChItem a (Stream a)
import Prelude
import Control.Concurrent.MVar
+import Data.Typeable
+
+#include "Typeable.h"
-- General semaphores are also implemented readily in terms of shared
-- @MVar@s, only have to catch the case when the semaphore is tried
-- \"quantity\" is always dealt with in units of one.
newtype QSem = QSem (MVar (Int, [MVar ()]))
+INSTANCE_TYPEABLE0(QSem,qSemTc,"QSem")
+
-- |Build a new 'QSem'
newQSem :: Int -> IO QSem
newQSem init = do
import Prelude
import Control.Concurrent.MVar
+import Data.Typeable
+
+#include "Typeable.h"
-- |A 'QSemN' is a quantity semaphore, in which the available
-- \"quantity\" may be signalled or waited for in arbitrary amounts.
newtype QSemN = QSemN (MVar (Int,[(Int,MVar ())]))
+INSTANCE_TYPEABLE0(QSemN,qSemNTc,"QSemN")
+
-- |Build a new 'QSemN' with a supplied initial quantity.
newQSemN :: Int -> IO QSemN
newQSemN init = do