11module Control.Monad.IO
22 ( module Control.Monad.IO.Effect
33 , IO (..)
4+ , ParIO (..)
45 , runIO
56 , runIO'
67 , launchIO
78 ) where
89
10+ import Prelude
11+
912import Control.Alt (class Alt )
1013import Control.Alternative (class Alternative )
11- import Control.Monad.Aff (Aff , launchAff )
12- import Control.Monad.Aff.Class (class MonadAff )
14+ import Control.Monad.Aff (Aff , ParAff (..), launchAff )
15+ import Control.Monad.Aff.Class (class MonadAff , liftAff )
1316import Control.Monad.Aff.Unsafe (unsafeCoerceAff )
1417import Control.Monad.Eff.Class (class MonadEff , liftEff )
1518import Control.Monad.Eff.Exception (Error )
@@ -19,13 +22,16 @@ import Control.Monad.IO.Effect (INFINITY)
1922import Control.Monad.IOSync (IOSync )
2023import Control.Monad.Rec.Class (class MonadRec )
2124import Control.MonadZero (class MonadZero )
25+ import Control.Parallel (class Parallel , parallel , sequential )
2226import Control.Plus (class Plus )
2327import Data.Monoid (class Monoid )
2428import Data.Newtype (class Newtype , unwrap , wrap )
2529import Prelude
2630
2731newtype IO a = IO (Aff (infinity :: INFINITY ) a )
2832
33+ newtype ParIO a = ParIO (ParAff (infinity :: INFINITY ) a )
34+
2935runIO :: IO ~> Aff (infinity :: INFINITY )
3036runIO = unwrap
3137
@@ -42,16 +48,23 @@ derive newtype instance applyIO :: Apply IO
4248derive newtype instance applicativeIO :: Applicative IO
4349derive newtype instance bindIO :: Bind IO
4450derive newtype instance monadIO :: Monad IO
51+ derive newtype instance monadRecIO :: MonadRec IO
52+ derive newtype instance semigroupIO :: (Semigroup a ) => Semigroup (IO a )
53+ derive newtype instance monoidIO :: (Monoid a ) => Monoid (IO a )
4554
46- derive newtype instance monadRecIO :: MonadRec IO
47-
48- derive newtype instance semigroupIO :: ( Semigroup a ) => Semigroup ( IO a )
49-
50- derive newtype instance monoidIO :: (Monoid a ) => Monoid (IO a )
55+ derive newtype instance functorParIO :: Functor ParIO
56+ derive newtype instance applyParIO :: Apply ParIO
57+ derive newtype instance applicativeParIO :: Applicative ParIO
58+ derive newtype instance semigroupParIO :: ( Semigroup a ) => Semigroup ( IO a )
59+ derive newtype instance monoidParIO :: (Monoid a ) => Monoid (IO a )
5160
5261instance monadAffIO :: MonadAff eff IO where
5362 liftAff = wrap <<< unsafeCoerceAff
5463
64+ instance parallelParIO :: Parallel ParIO IO where
65+ parallel = ParIO <<< ParAff <<< runIO
66+ sequential (ParIO (ParAff ma)) = IO ma
67+
5568instance monadEffIO :: MonadEff eff IO where
5669 liftEff = wrap <<< liftEff <<< unsafeCoerceEff
5770
0 commit comments