Skip to content

Commit d3a75a7

Browse files
committed
strict-stm: added castStrict{TQueue,TBQueue,TChan}
castStrictTArray is not possible with ghc
1 parent 4a617f2 commit d3a75a7

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

strict-stm/src/Control/Concurrent/Class/MonadSTM/Strict/TBQueue.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module Control.Concurrent.Class.MonadSTM.Strict.TBQueue
1111
, LazyTBQueue
1212
, toLazyTBQueue
1313
, fromLazyTBQueue
14+
, castStrictTBQueue
1415
, newTBQueue
1516
, newTBQueueIO
1617
, readTBQueue
@@ -45,6 +46,10 @@ newtype StrictTBQueue m a = StrictTBQueue { toLazyTBQueue :: LazyTBQueue m a }
4546
fromLazyTBQueue :: LazyTBQueue m a -> StrictTBQueue m a
4647
fromLazyTBQueue = StrictTBQueue
4748

49+
castStrictTBQueue :: LazyTBQueue m ~ LazyTBQueue n
50+
=> StrictTBQueue m a -> StrictTBQueue n a
51+
castStrictTBQueue (StrictTBQueue var) = StrictTBQueue var
52+
4853
labelTBQueue :: MonadLabelledSTM m => StrictTBQueue m a -> String -> STM m ()
4954
labelTBQueue (StrictTBQueue queue) = Lazy.labelTBQueue queue
5055

strict-stm/src/Control/Concurrent/Class/MonadSTM/Strict/TChan.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module Control.Concurrent.Class.MonadSTM.Strict.TChan
1111
, LazyTChan
1212
, toLazyTChan
1313
, fromLazyTChan
14+
, castStrictTChan
1415
, newTChan
1516
, newBroadcastTChan
1617
, writeTChan
@@ -36,6 +37,10 @@ newtype StrictTChan m a = StrictTChan { toLazyTChan :: LazyTChan m a }
3637
fromLazyTChan :: LazyTChan m a -> StrictTChan m a
3738
fromLazyTChan = StrictTChan
3839

40+
castStrictTChan :: LazyTChan m ~ LazyTChan n
41+
=> StrictTChan m a -> StrictTChan n a
42+
castStrictTChan (StrictTChan var) = StrictTChan var
43+
3944
newTChan :: MonadSTM m => STM m (StrictTChan m a)
4045
newTChan = StrictTChan <$> Lazy.newTChan
4146

strict-stm/src/Control/Concurrent/Class/MonadSTM/Strict/TQueue.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ module Control.Concurrent.Class.MonadSTM.Strict.TQueue
1212
, LazyTQueue
1313
, toLazyTQueue
1414
, fromLazyTQueue
15+
, castStrictTQueue
1516
, newTQueue
1617
, newTQueueIO
1718
, readTQueue
@@ -42,6 +43,10 @@ newtype StrictTQueue m a = StrictTQueue { toLazyTQueue :: LazyTQueue m a }
4243
fromLazyTQueue :: LazyTQueue m a -> StrictTQueue m a
4344
fromLazyTQueue = StrictTQueue
4445

46+
castStrictTQueue :: LazyTQueue m ~ LazyTQueue n
47+
=> StrictTQueue m a -> StrictTQueue n a
48+
castStrictTQueue (StrictTQueue var) = StrictTQueue var
49+
4550
labelTQueue :: MonadLabelledSTM m => StrictTQueue m a -> String -> STM m ()
4651
labelTQueue (StrictTQueue queue) = Lazy.labelTQueue queue
4752

0 commit comments

Comments
 (0)