Skip to content

Commit

Permalink
simplify Freer bind
Browse files Browse the repository at this point in the history
  • Loading branch information
echatav committed Oct 12, 2020
1 parent 940a42f commit 2e591bc
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Control/Monad/Trans/Indexed/Free/Lance.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ deriving newtype instance Monad m => Functor (FreeIx f i j m)
instance SFunctor FreeIx where
smap f (FreeIx wrapped) = FreeIx (smap (mapLance f) wrapped)
instance SFoldable FreeIx where
sfoldMap f (FreeIx wrapped) = sfoldMap (foldLance f) wrapped
sfoldMap f (FreeIx wrapped) = sfoldMap (f . lowerLance) wrapped
instance SPointed FreeIx where
slift = FreeIx . slift . liftLance
instance SMonad FreeIx where
Expand All @@ -63,10 +63,10 @@ instance i ~ j => MonadTrans (FreeIx f i j) where
lift = FreeIx . Wrap.FreeIx . fmap Wrap.Unwrap
instance IndexedMonadTrans (FreeIx f) where
ixBind g (FreeIx (Wrap.FreeIx m)) = do
FreeIx . Wrap.FreeIx $ m >>= Wrap.runFreeIx . \case
Wrap.Unwrap x -> runFreeIx (g x)
Wrap.Wrap (Lance f y) ->
ixBind (ixAndThen (runFreeIx . g) f) (slift (liftLance y))
FreeIx . Wrap.FreeIx $ m >>= \case
Wrap.Unwrap x -> Wrap.runFreeIx (runFreeIx (g x))
Wrap.Wrap (Lance f y) -> return $
Wrap.Wrap (Lance (ixAndThen (runFreeIx . g) f) y)
instance
( Monad m
, i ~ j
Expand Down

0 comments on commit 2e591bc

Please sign in to comment.