[project @ 2004-12-14 12:52:03 by simonmar]
authorsimonmar <unknown>
Tue, 14 Dec 2004 12:52:03 +0000 (12:52 +0000)
committersimonmar <unknown>
Tue, 14 Dec 2004 12:52:03 +0000 (12:52 +0000)
Some more Typeable instances, as requested on the ghc-users list a while back.

Control/Concurrent/Chan.hs
Control/Concurrent/QSem.hs
Control/Concurrent/QSemN.hs

index 1b89f29..6b48e33 100644 (file)
@@ -34,6 +34,9 @@ import Prelude
 
 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
@@ -44,6 +47,8 @@ data Chan a
  = 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)
index 2ef6dff..5a512d8 100644 (file)
@@ -22,6 +22,9 @@ module Control.Concurrent.QSem
 
 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
@@ -34,6 +37,8 @@ import Control.Concurrent.MVar
 -- \"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
index d8d6f49..56c5e50 100644 (file)
@@ -24,11 +24,16 @@ module Control.Concurrent.QSemN
 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