Skip to content
Browse files

Added Control.Concurrent.SampleVar.Lifted

  • Loading branch information...
1 parent 0a5515d commit 92d10b06b4b5818d122addd4ee562114e3cc2d3d @liyang committed
Showing with 82 additions and 1 deletion.
  1. +2 −1 Control/Concurrent/Lifted.hs
  2. +79 −0 Control/Concurrent/SampleVar/Lifted.hs
  3. +1 −0 lifted-base.cabal
View
3 Control/Concurrent/Lifted.hs
@@ -47,7 +47,7 @@ module Control.Concurrent.Lifted
, module Control.Concurrent.Chan.Lifted
, module Control.Concurrent.QSem.Lifted
, module Control.Concurrent.QSemN.Lifted
- -- TODO: , module Control.Concurrent.SampleVar.Lifted
+ , module Control.Concurrent.SampleVar.Lifted
-- * Merging of streams
, merge
@@ -95,6 +95,7 @@ import Control.Concurrent.MVar.Lifted
import Control.Concurrent.Chan.Lifted
import Control.Concurrent.QSem.Lifted
import Control.Concurrent.QSemN.Lifted
+import Control.Concurrent.SampleVar.Lifted
#include "inlinable.h"
View
79 Control/Concurrent/SampleVar/Lifted.hs
@@ -0,0 +1,79 @@
+{-# LANGUAGE CPP #-}
+{-# LANGUAGE UnicodeSyntax #-}
+{-# LANGUAGE NoImplicitPrelude #-}
+{-# LANGUAGE FlexibleContexts #-}
+
+{- |
+Module : Control.Concurrent.SampleVar.Lifted
+Copyright : Liyang HU, Bas van Dijk
+License : BSD-style
+
+Maintainer : Bas van Dijk <v.dijk.bas@gmail.com>
+Stability : experimental
+
+This is a wrapped version of 'Control.Concurrent.SampleVar' with types
+generalised from @IO@ to all monads in 'MonadBase'.
+-}
+
+module Control.Concurrent.SampleVar.Lifted
+ ( SampleVar
+ , newEmptySampleVar
+ , newSampleVar
+ , emptySampleVar
+ , readSampleVar
+ , writeSampleVar
+ , isEmptySampleVar
+ ) where
+
+--------------------------------------------------------------------------------
+-- Imports
+--------------------------------------------------------------------------------
+
+-- from base:
+import Control.Concurrent.SampleVar ( SampleVar )
+import qualified Control.Concurrent.SampleVar as SampleVar
+import Data.Bool ( Bool )
+import System.IO ( IO )
+
+-- from base-unicode-symbols:
+import Data.Function.Unicode ( (∘) )
+
+-- from transformers-base:
+import Control.Monad.Base ( MonadBase, liftBase )
+
+#include "inlinable.h"
+
+--------------------------------------------------------------------------------
+-- * SampleVars
+--------------------------------------------------------------------------------
+
+-- | Generalized version of 'SampleVar.newEmptySampleVar'.
+newEmptySampleVar MonadBase IO m m (SampleVar a)
+newEmptySampleVar = liftBase SampleVar.newEmptySampleVar
+{-# INLINABLE newEmptySampleVar #-}
+
+-- | Generalized version of 'SampleVar.newSampleVar'.
+newSampleVar MonadBase IO m a m (SampleVar a)
+newSampleVar = liftBase SampleVar.newSampleVar
+{-# INLINABLE newSampleVar #-}
+
+-- | Generalized version of 'SampleVar.emptySampleVar'.
+emptySampleVar MonadBase IO m SampleVar a m ()
+emptySampleVar = liftBase SampleVar.emptySampleVar
+{-# INLINABLE emptySampleVar #-}
+
+-- | Generalized version of 'SampleVar.readSampleVar'.
+readSampleVar MonadBase IO m SampleVar a m a
+readSampleVar = liftBase SampleVar.readSampleVar
+{-# INLINABLE readSampleVar #-}
+
+-- | Generalized version of 'SampleVar.writeSampleVar'.
+writeSampleVar MonadBase IO m SampleVar a a m ()
+writeSampleVar sv = liftBase SampleVar.writeSampleVar sv
+{-# INLINABLE writeSampleVar #-}
+
+-- | Generalized version of 'SampleVar.isEmptySampleVar'.
+isEmptySampleVar MonadBase IO m SampleVar a m Bool
+isEmptySampleVar = liftBase SampleVar.isEmptySampleVar
+{-# INLINABLE isEmptySampleVar #-}
+
View
1 lifted-base.cabal
@@ -39,6 +39,7 @@ Library
Control.Concurrent.Chan.Lifted
Control.Concurrent.QSem.Lifted
Control.Concurrent.QSemN.Lifted
+ Control.Concurrent.SampleVar.Lifted
Control.Concurrent.Lifted
System.Timeout.Lifted

0 comments on commit 92d10b0

Please sign in to comment.
Something went wrong with that request. Please try again.