From: simonmar Date: Tue, 14 Dec 2004 12:52:03 +0000 (+0000) Subject: [project @ 2004-12-14 12:52:03 by simonmar] X-Git-Tag: nhc98-1-18-release~160 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=edc5c57d653289a1cf8dd2b05bf94ed25975e28a;p=ghc-base.git [project @ 2004-12-14 12:52:03 by simonmar] Some more Typeable instances, as requested on the ghc-users list a while back. --- diff --git a/Control/Concurrent/Chan.hs b/Control/Concurrent/Chan.hs index 1b89f29..6b48e33 100644 --- a/Control/Concurrent/Chan.hs +++ b/Control/Concurrent/Chan.hs @@ -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) diff --git a/Control/Concurrent/QSem.hs b/Control/Concurrent/QSem.hs index 2ef6dff..5a512d8 100644 --- a/Control/Concurrent/QSem.hs +++ b/Control/Concurrent/QSem.hs @@ -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 diff --git a/Control/Concurrent/QSemN.hs b/Control/Concurrent/QSemN.hs index d8d6f49..56c5e50 100644 --- a/Control/Concurrent/QSemN.hs +++ b/Control/Concurrent/QSemN.hs @@ -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