@@ -11,7 +11,6 @@ import Control.Monad.Trans.Class (class MonadTrans, lift)
1111import Control.Monad.Writer (class MonadTell , tell )
1212import Control.Parallel (class Parallel )
1313import Data.Bifunctor (lmap )
14- import Data.Newtype (class Newtype , over )
1514import Data.Tuple (Tuple )
1615import Effect.Aff.Class (class MonadAff , liftAff )
1716import Effect.Class (class MonadEffect , liftEffect )
@@ -90,13 +89,13 @@ instance monadRecHaloM :: MonadRec (HaloM props state action m) where
9089 Done y -> pure y
9190
9291instance monadAskHaloM :: MonadAsk r m => MonadAsk r (HaloM props state action m ) where
93- ask = HaloM $ liftF $ Lift ask
92+ ask = lift ask
9493
9594instance monadTellHaloM :: MonadTell w m => MonadTell w (HaloM props state action m ) where
96- tell = HaloM <<< liftF <<< Lift <<< tell
95+ tell = lift <<< tell
9796
9897instance monadThrowHaloM :: MonadThrow e m => MonadThrow e (HaloM props state action m ) where
99- throwError = HaloM <<< liftF <<< Lift <<< throwError
98+ throwError = lift <<< throwError
10099
101100-- | The Halo parallel evaluation applicative. It lifts `HaloM` into a free applicative.
102101-- |
@@ -108,8 +107,6 @@ instance monadThrowHaloM :: MonadThrow e m => MonadThrow e (HaloM props state ac
108107newtype HaloAp props state action m a
109108 = HaloAp (FreeAp (HaloM props state action m ) a )
110109
111- derive instance newtypeHaloAp :: Newtype (HaloAp props state action m a ) _
112-
113110derive newtype instance functorHaloAp :: Functor (HaloAp props state action m )
114111
115112derive newtype instance applyHaloAp :: Apply (HaloAp props state action m )
@@ -131,10 +128,14 @@ hoist nat (HaloM component) = HaloM (hoistFree go component)
131128 Subscribe event k -> Subscribe event k
132129 Unsubscribe sid a -> Unsubscribe sid a
133130 Lift m -> Lift (nat m)
134- Par par -> Par (over HaloAp (hoistFreeAp (hoist nat)) par)
131+ Par par -> Par (hoistAp nat par)
135132 Fork m k -> Fork (hoist nat m) k
136133 Kill fid a -> Kill fid a
137134
135+ -- | Hoist (transform) the base applicative of a `HaloAp` expression.
136+ hoistAp :: forall props state action m m' . Functor m => (m ~> m' ) -> HaloAp props state action m ~> HaloAp props state action m'
137+ hoistAp nat (HaloAp component) = HaloAp (hoistFreeAp (hoist nat) component)
138+
138139-- | Read the current props.
139140props :: forall props m action state . HaloM props state action m props
140141props = HaloM (liftF (Props identity))
0 commit comments