Skip to content

Commit

Permalink
Fix issue #3. Replaced Unicode type variables with ASCII.
Browse files Browse the repository at this point in the history
  • Loading branch information
basvandijk committed Apr 21, 2012
1 parent 10e4898 commit c260fb6
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 62 deletions.
12 changes: 6 additions & 6 deletions Control/Concurrent/Lifted.hs
Expand Up @@ -120,7 +120,7 @@ fork = liftBaseDiscard C.forkIO
-- Note that, while the forked computation @m ()@ has access to the captured
-- state, all its side-effects in @m@ are discarded. It is run only for its
-- side-effects in 'IO'.
forkWithUnmask MonadBaseControl IO m (( α. m α m α) m ()) m ThreadId
forkWithUnmask MonadBaseControl IO m (( a. m a m a) m ()) m ThreadId
forkWithUnmask f = liftBaseWith $ \runInIO
C.forkIOWithUnmask $ \unmask
void $ runInIO $ f $ liftBaseOp_ unmask
Expand Down Expand Up @@ -152,7 +152,7 @@ forkOn = liftBaseDiscard ∘ C.forkOn
-- Note that, while the forked computation @m ()@ has access to the captured
-- state, all its side-effects in @m@ are discarded. It is run only for its
-- side-effects in 'IO'.
forkOnWithUnmask MonadBaseControl IO m Int (( α. m α m α) m ()) m ThreadId
forkOnWithUnmask MonadBaseControl IO m Int (( a. m a m a) m ()) m ThreadId
forkOnWithUnmask cap f = liftBaseWith $ \runInIO
C.forkOnWithUnmask cap $ \unmask
void $ runInIO $ f $ liftBaseOp_ unmask
Expand Down Expand Up @@ -190,12 +190,12 @@ threadWaitWrite = liftBase ∘ C.threadWaitWrite
{-# INLINABLE threadWaitWrite #-}

-- | Generalized version of 'C.mergeIO'.
merge MonadBase IO m [α] [α] m [α]
merge MonadBase IO m [a] [a] m [a]
merge xs ys = liftBase $ C.mergeIO xs ys
{-# INLINABLE merge #-}

-- | Generalized version of 'C.nmergeIO'.
nmerge MonadBase IO m [[α]] m [α]
nmerge MonadBase IO m [[a]] m [a]
nmerge = liftBase C.nmergeIO
{-# INLINABLE nmerge #-}

Expand All @@ -214,11 +214,11 @@ isCurrentThreadBound = liftBase C.isCurrentThreadBound
{-# INLINABLE isCurrentThreadBound #-}

-- | Generalized version of 'C.runInBoundThread'.
runInBoundThread MonadBaseControl IO m m α m α
runInBoundThread MonadBaseControl IO m m a m a
runInBoundThread = liftBaseOp_ C.runInBoundThread
{-# INLINABLE runInBoundThread #-}

-- | Generalized version of 'C.runInUnboundThread'.
runInUnboundThread MonadBaseControl IO m m α m α
runInUnboundThread MonadBaseControl IO m m a m a
runInUnboundThread = liftBaseOp_ C.runInUnboundThread
{-# INLINABLE runInUnboundThread #-}
26 changes: 13 additions & 13 deletions Control/Concurrent/MVar/Lifted.hs
Expand Up @@ -81,62 +81,62 @@ import Control.Monad.Trans.Control ( MonadBaseControl
--------------------------------------------------------------------------------

-- | Generalized version of 'MVar.newEmptyMVar'.
newEmptyMVar MonadBase IO m m (MVar α)
newEmptyMVar MonadBase IO m m (MVar a)
newEmptyMVar = liftBase MVar.newEmptyMVar
{-# INLINABLE newEmptyMVar #-}

-- | Generalized version of 'MVar.newMVar'.
newMVar MonadBase IO m α m (MVar α)
newMVar MonadBase IO m a m (MVar a)
newMVar = liftBase MVar.newMVar
{-# INLINABLE newMVar #-}

-- | Generalized version of 'MVar.takeMVar'.
takeMVar MonadBase IO m MVar α m α
takeMVar MonadBase IO m MVar a m a
takeMVar = liftBase MVar.takeMVar
{-# INLINABLE takeMVar #-}

-- | Generalized version of 'MVar.putMVar'.
putMVar MonadBase IO m MVar α α m ()
putMVar MonadBase IO m MVar a a m ()
putMVar mv x = liftBase $ MVar.putMVar mv x
{-# INLINABLE putMVar #-}

-- | Generalized version of 'MVar.readMVar'.
readMVar MonadBase IO m MVar α m α
readMVar MonadBase IO m MVar a m a
readMVar = liftBase MVar.readMVar
{-# INLINABLE readMVar #-}

-- | Generalized version of 'MVar.swapMVar'.
swapMVar MonadBase IO m MVar α α m α
swapMVar MonadBase IO m MVar a a m a
swapMVar mv x = liftBase $ MVar.swapMVar mv x
{-# INLINABLE swapMVar #-}

-- | Generalized version of 'MVar.tryTakeMVar'.
tryTakeMVar MonadBase IO m MVar α m (Maybe α)
tryTakeMVar MonadBase IO m MVar a m (Maybe a)
tryTakeMVar = liftBase MVar.tryTakeMVar
{-# INLINABLE tryTakeMVar #-}

-- | Generalized version of 'MVar.tryPutMVar'.
tryPutMVar MonadBase IO m MVar α α m Bool
tryPutMVar MonadBase IO m MVar a a m Bool
tryPutMVar mv x = liftBase $ MVar.tryPutMVar mv x
{-# INLINABLE tryPutMVar #-}

-- | Generalized version of 'MVar.isEmptyMVar'.
isEmptyMVar MonadBase IO m MVar α m Bool
isEmptyMVar MonadBase IO m MVar a m Bool
isEmptyMVar = liftBase MVar.isEmptyMVar
{-# INLINABLE isEmptyMVar #-}

-- | Generalized version of 'MVar.withMVar'.
withMVar MonadBaseControl IO m MVar α (α m β) m β
withMVar MonadBaseControl IO m MVar a (a m b) m b
withMVar = liftBaseOp MVar.withMVar
{-# INLINABLE withMVar #-}

-- | Generalized version of 'MVar.modifyMVar_'.
modifyMVar_ (MonadBaseControl IO m) MVar α (α m α) m ()
modifyMVar_ (MonadBaseControl IO m) MVar a (a m a) m ()
modifyMVar_ mv = modifyMVar mv (fmap (, ()) )
{-# INLINABLE modifyMVar_ #-}

-- | Generalized version of 'MVar.modifyMVar'.
modifyMVar (MonadBaseControl IO m) MVar α (α m (α, β)) m β
modifyMVar (MonadBaseControl IO m) MVar a (a m (a, b)) m b

#if MIN_VERSION_base(4,3,0)
modifyMVar mv f = control $ \runInIO -> mask $ \restore do
Expand Down Expand Up @@ -173,6 +173,6 @@ modifyMVar mv f = control $ \runInIO -> block $ do
--
-- Note any monadic side effects in @m@ of the \"finalizer\" computation are
-- discarded.
addMVarFinalizer MonadBaseControl IO m MVar α m () m ()
addMVarFinalizer MonadBaseControl IO m MVar a m () m ()
addMVarFinalizer = liftBaseDiscard MVar.addMVarFinalizer
{-# INLINABLE addMVarFinalizer #-}
82 changes: 41 additions & 41 deletions Control/Exception/Lifted.hs
Expand Up @@ -127,12 +127,12 @@ import Control.Monad.Trans.Control ( liftBaseOp )
--------------------------------------------------------------------------------

-- |Generalized version of 'E.throwIO'.
throwIO (MonadBase IO m, Exception e) e m α
throwIO (MonadBase IO m, Exception e) e m a
throwIO = liftBase E.throwIO
{-# INLINABLE throwIO #-}

-- |Generalized version of 'E.ioError'.
ioError MonadBase IO m IOError m α
ioError MonadBase IO m IOError m a
ioError = liftBase E.ioError
{-# INLINABLE ioError #-}

Expand All @@ -143,16 +143,16 @@ ioError = liftBase ∘ E.ioError

-- |Generalized version of 'E.catch'.
catch (MonadBaseControl IO m, Exception e)
m α -- ^ The computation to run
(e m α) -- ^ Handler to invoke if an exception is raised
m α
m a -- ^ The computation to run
(e m a) -- ^ Handler to invoke if an exception is raised
m a
catch a handler = control $ \runInIO
E.catch (runInIO a)
(\e runInIO $ handler e)
{-# INLINABLE catch #-}

-- |Generalized version of 'E.catches'.
catches MonadBaseControl IO m m α [Handler m α] m α
catches MonadBaseControl IO m m a [Handler m a] m a
catches a handlers = control $ \runInIO
E.catches (runInIO a)
[ E.Handler $ \e runInIO $ handler e
Expand All @@ -161,14 +161,14 @@ catches a handlers = control $ \runInIO →
{-# INLINABLE catches #-}

-- |Generalized version of 'E.Handler'.
data Handler m α = ∀ e. Exception e Handler (e m α)
data Handler m a = ∀ e. Exception e Handler (e m a)

-- |Generalized version of 'E.catchJust'.
catchJust (MonadBaseControl IO m, Exception e)
(e Maybe β) -- ^ Predicate to select exceptions
m α -- ^ Computation to run
(β m α) -- ^ Handler
m α
(e Maybe b) -- ^ Predicate to select exceptions
m a -- ^ Computation to run
(b m a) -- ^ Handler
m a
catchJust p a handler = control $ \runInIO
E.catchJust p
(runInIO a)
Expand All @@ -181,15 +181,15 @@ catchJust p a handler = control $ \runInIO →
--------------------------------------------------------------------------------

-- |Generalized version of 'E.handle'.
handle (MonadBaseControl IO m, Exception e) (e m α) m α m α
handle (MonadBaseControl IO m, Exception e) (e m a) m a m a
handle handler a = control $ \runInIO
E.handle (\e runInIO (handler e))
(runInIO a)
{-# INLINABLE handle #-}

-- |Generalized version of 'E.handleJust'.
handleJust (MonadBaseControl IO m, Exception e)
(e Maybe β) (β m α) m α m α
(e Maybe b) (b m a) m a m a
handleJust p handler a = control $ \runInIO
E.handleJust p (\e runInIO (handler e))
(runInIO a)
Expand All @@ -199,17 +199,17 @@ handleJust p handler a = control $ \runInIO →
-- ** The @try@ functions
--------------------------------------------------------------------------------

sequenceEither MonadBaseControl IO m Either e (StM m α) m (Either e α)
sequenceEither MonadBaseControl IO m Either e (StM m a) m (Either e a)
sequenceEither = either (return Left) (liftM Right restoreM)
{-# INLINE sequenceEither #-}

-- |Generalized version of 'E.try'.
try (MonadBaseControl IO m, Exception e) m α m (Either e α)
try (MonadBaseControl IO m, Exception e) m a m (Either e a)
try m = liftBaseWith (\runInIO E.try (runInIO m)) >>= sequenceEither
{-# INLINABLE try #-}

-- |Generalized version of 'E.tryJust'.
tryJust (MonadBaseControl IO m, Exception e) (e Maybe β) m α m (Either β α)
tryJust (MonadBaseControl IO m, Exception e) (e Maybe b) m a m (Either b a)
tryJust p m = liftBaseWith (\runInIO E.tryJust p (runInIO m)) >>= sequenceEither
{-# INLINABLE tryJust #-}

Expand All @@ -219,7 +219,7 @@ tryJust p m = liftBaseWith (\runInIO → E.tryJust p (runInIO m)) >>= sequenceEi
--------------------------------------------------------------------------------

-- |Generalized version of 'E.evaluate'.
evaluate MonadBase IO m α m α
evaluate MonadBase IO m a m a
evaluate = liftBase E.evaluate
{-# INLINABLE evaluate #-}

Expand All @@ -230,28 +230,28 @@ evaluate = liftBase ∘ E.evaluate

#if MIN_VERSION_base(4,3,0)
-- |Generalized version of 'E.mask'.
mask MonadBaseControl IO m (( α. m α m α) m β) m β
mask MonadBaseControl IO m (( a. m a m a) m b) m b
mask = liftBaseOp E.mask liftRestore
{-# INLINABLE mask #-}

liftRestore MonadBaseControl IO m
(( α. m α m α) β)
(( α. IO α IO α) β)
(( a. m a m a) b)
(( a. IO a IO a) b)
liftRestore f r = f $ liftBaseOp_ r
{-# INLINE liftRestore #-}

-- |Generalized version of 'E.mask_'.
mask_ MonadBaseControl IO m m α m α
mask_ MonadBaseControl IO m m a m a
mask_ = liftBaseOp_ E.mask_
{-# INLINABLE mask_ #-}

-- |Generalized version of 'E.uninterruptibleMask'.
uninterruptibleMask MonadBaseControl IO m (( α. m α m α) m β) m β
uninterruptibleMask MonadBaseControl IO m (( a. m a m a) m b) m b
uninterruptibleMask = liftBaseOp E.uninterruptibleMask liftRestore
{-# INLINABLE uninterruptibleMask #-}

-- |Generalized version of 'E.uninterruptibleMask_'.
uninterruptibleMask_ MonadBaseControl IO m m α m α
uninterruptibleMask_ MonadBaseControl IO m m a m a
uninterruptibleMask_ = liftBaseOp_ E.uninterruptibleMask_
{-# INLINABLE uninterruptibleMask_ #-}

Expand All @@ -261,12 +261,12 @@ getMaskingState = liftBase E.getMaskingState
{-# INLINABLE getMaskingState #-}
#else
-- |Generalized version of 'E.block'.
block MonadBaseControl IO m m α m α
block MonadBaseControl IO m m a m a
block = liftBaseOp_ E.block
{-# INLINABLE block #-}

-- |Generalized version of 'E.unblock'.
unblock MonadBaseControl IO m m α m α
unblock MonadBaseControl IO m m a m a
unblock = liftBaseOp_ E.unblock
{-# INLINABLE unblock #-}
#endif
Expand Down Expand Up @@ -294,10 +294,10 @@ blocked = liftBase E.blocked
--
-- @'liftBaseOp' ('E.bracket' acquire release)@
bracket MonadBaseControl IO m
m α -- ^ computation to run first (\"acquire resource\")
(α m β) -- ^ computation to run last (\"release resource\")
(α m γ) -- ^ computation to run in-between
m γ
m a -- ^ computation to run first (\"acquire resource\")
(a m b) -- ^ computation to run last (\"release resource\")
(a m c) -- ^ computation to run in-between
m c
bracket before after thing = control $ \runInIO
E.bracket (runInIO before)
(\st runInIO $ restoreM st >>= after)
Expand All @@ -315,10 +315,10 @@ bracket before after thing = control $ \runInIO →
--
-- @'liftBaseOp_' ('E.bracket_' acquire release)@
bracket_ MonadBaseControl IO m
m α -- ^ computation to run first (\"acquire resource\")
m β -- ^ computation to run last (\"release resource\")
m γ -- ^ computation to run in-between
m γ
m a -- ^ computation to run first (\"acquire resource\")
m b -- ^ computation to run last (\"release resource\")
m c -- ^ computation to run in-between
m c
bracket_ before after thing = control $ \runInIO
E.bracket_ (runInIO before)
(runInIO after)
Expand All @@ -333,10 +333,10 @@ bracket_ before after thing = control $ \runInIO →
--
-- @'liftBaseOp' ('E.bracketOnError' acquire release)@
bracketOnError MonadBaseControl IO m
m α -- ^ computation to run first (\"acquire resource\")
(α m β) -- ^ computation to run last (\"release resource\")
(α m γ) -- ^ computation to run in-between
m γ
m a -- ^ computation to run first (\"acquire resource\")
(a m b) -- ^ computation to run last (\"release resource\")
(a m c) -- ^ computation to run in-between
m c
bracketOnError before after thing =
control $ \runInIO
E.bracketOnError (runInIO before)
Expand All @@ -352,17 +352,17 @@ bracketOnError before after thing =
-- |Generalized version of 'E.finally'. Note, any monadic side
-- effects in @m@ of the \"afterward\" computation will be discarded.
finally MonadBaseControl IO m
m α -- ^ computation to run first
m β -- ^ computation to run afterward (even if an exception was raised)
m α
m a -- ^ computation to run first
m b -- ^ computation to run afterward (even if an exception was raised)
m a
finally a sequel = control $ \runInIO
E.finally (runInIO a)
(runInIO sequel)
{-# INLINABLE finally #-}

-- |Generalized version of 'E.onException'. Note, any monadic side
-- effects in @m@ of the \"afterward\" computation will be discarded.
onException MonadBaseControl IO m m α m β m α
onException MonadBaseControl IO m m a m b m a
onException m what = control $ \runInIO
E.onException (runInIO m)
(runInIO what)
Expand Down
2 changes: 1 addition & 1 deletion System/Timeout/Lifted.hs
Expand Up @@ -37,7 +37,7 @@ import Control.Monad.Trans.Control ( MonadBaseControl, restoreM, liftBaseWith )
-- Note that when the given computation times out any side effects of @m@ are
-- discarded. When the computation completes within the given time the
-- side-effects are restored on return.
timeout MonadBaseControl IO m Int m α m (Maybe α)
timeout MonadBaseControl IO m Int m a m (Maybe a)
timeout t m = liftBaseWith (\runInIO T.timeout t (runInIO m)) >>=
maybe (return Nothing) (liftM Just restoreM)
{-# INLINABLE timeout #-}
2 changes: 1 addition & 1 deletion lifted-base.cabal
@@ -1,5 +1,5 @@
Name: lifted-base
Version: 0.1.0.3
Version: 0.1.0.4
Synopsis: lifted IO operations from the base library
License: BSD3
License-file: LICENSE
Expand Down

0 comments on commit c260fb6

Please sign in to comment.