File: Lifted.hs

package info (click to toggle)
haskell-lifted-base 0.2.3.12-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 144 kB
  • sloc: haskell: 982; ansic: 3; makefile: 3
file content (79 lines) | stat: -rw-r--r-- 2,549 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
{-# LANGUAGE CPP #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE FlexibleContexts #-}

#if __GLASGOW_HASKELL__ >= 702
{-# LANGUAGE Trustworthy #-}
#endif

{- |
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 )
import Prelude ( (.) )

-- 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 #-}