git.iko.soy/distributed-process
on master help sign in
MonadControl instance for Process.
53c7fe6Alexander Vershilov
distributed-process.cabal+3−1
@@ -54,7 +54,9 @@ Library
54 ghc-prim >= 0.2 && < 0.5,
54 ghc-prim >= 0.2 && < 0.5,
55 distributed-static >= 0.2 && < 0.4,
55 distributed-static >= 0.2 && < 0.4,
56 rank1dynamic >= 0.1 && < 0.4,
56 rank1dynamic >= 0.1 && < 0.4,
57− syb >= 0.3 && < 0.7
57+ syb >= 0.3 && < 0.7,
58+ transformers-base >= 0.3 && < 0.5,
59+ monad-control >= 0.3 && < 0.4
58 Exposed-modules: Control.Distributed.Process,
60 Exposed-modules: Control.Distributed.Process,
59 Control.Distributed.Process.Closure,
61 Control.Distributed.Process.Closure,
60 Control.Distributed.Process.Debug,
62 Control.Distributed.Process.Debug,
src/Control/Distributed/Process/Internal/Types.hs+22−4
@@ -1,9 +1,11 @@
1+{-# LANGUAGE CPP #-}
1{-# LANGUAGE DeriveDataTypeable #-}
2{-# LANGUAGE DeriveDataTypeable #-}
3+{-# LANGUAGE DeriveGeneric #-}
2{-# LANGUAGE ExistentialQuantification #-}
4{-# LANGUAGE ExistentialQuantification #-}
3{-# LANGUAGE GeneralizedNewtypeDeriving #-}
5{-# LANGUAGE GeneralizedNewtypeDeriving #-}
4{-# LANGUAGE GADTs #-}
6{-# LANGUAGE GADTs #-}
5−{-# LANGUAGE DeriveGeneric #-}
7+{-# LANGUAGE MultiParamTypeClasses #-}
6−{-# LANGUAGE CPP #-}
8+{-# LANGUAGE TypeFamilies #-}
7
9
8-- | Types used throughout the Cloud Haskell framework
10-- | Types used throughout the Cloud Haskell framework
9--
11--
@@ -116,7 +118,9 @@ import qualified Network.Transport as NT (EndPoint, EndPointAddress, Connection)
116import Control.Applicative (Applicative, Alternative, (<$>), (<*>))
118import Control.Applicative (Applicative, Alternative, (<$>), (<*>))
117import Control.Monad.Fix (MonadFix)
119import Control.Monad.Fix (MonadFix)
118import Control.Monad.Reader (MonadReader(..), ReaderT, runReaderT)
120import Control.Monad.Reader (MonadReader(..), ReaderT, runReaderT)
119−import Control.Monad.IO.Class (MonadIO)
121+import Control.Monad.IO.Class (MonadIO(..))
122+import Control.Monad.Base (MonadBase(..))
123+import Control.Monad.Trans.Control (MonadBaseControl(..))
120import Control.Distributed.Process.Serializable
124import Control.Distributed.Process.Serializable
121 ( Fingerprint
125 ( Fingerprint
122 , Serializable
126 , Serializable
@@ -345,7 +349,21 @@ data LocalProcessState = LocalProcessState
345newtype Process a = Process {
349newtype Process a = Process {
346 unProcess :: ReaderT LocalProcess IO a
350 unProcess :: ReaderT LocalProcess IO a
347 }
351 }
352+ deriving ( Applicative, Functor, Monad, MonadFix, MonadIO
348− deriving (Functor, Monad, MonadIO, MonadReader LocalProcess, Typeable, Applicative, MonadFix)
353+ , MonadReader LocalProcess, Typeable
354+ )
355+
356+instance MonadBase IO Process where
357+ liftBase = liftIO
358+
359+instance MonadBaseControl IO Process where
360+ newtype StM Process a =
361+ StMProcess { unStMProcess :: StM (ReaderT LocalProcess IO) a }
362+
363+ liftBaseWith f = Process $ liftBaseWith $ \run ->
364+ f $ fmap StMProcess . run . unProcess
365+
366+ restoreM = Process . restoreM . unStMProcess
349
367
350--------------------------------------------------------------------------------
368--------------------------------------------------------------------------------
351-- Typed channels --
369-- Typed channels --