Skip to content

Commit

Permalink
foldable law for default signature
Browse files Browse the repository at this point in the history
  • Loading branch information
echatav committed Oct 7, 2020
1 parent 63e0132 commit 156b02b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
7 changes: 7 additions & 0 deletions src/Control/Monad/Trans/Indexed/Free.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{-# LANGUAGE
ConstraintKinds
, DefaultSignatures
, GADTs
, PolyKinds
, QuantifiedConstraints
Expand Down Expand Up @@ -75,6 +76,12 @@ class SPointed f => SMonad f where
:: (Silo g, Silo h, Monad m)
=> (forall i j x. g i j x -> f h i j m x)
-> f g i j m x -> f h i j m x
default sbind
:: IxFree f
=> (Silo g, Silo h, Monad m)
=> (forall i j x. g i j x -> f h i j m x)
-> f g i j m x -> f h i j m x
sbind = sfoldMap

coerceIxFree
:: (IxFree f0, IxFree f1, Silo g, Monad m)
Expand Down
3 changes: 1 addition & 2 deletions src/Control/Monad/Trans/Indexed/Free/Fold.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ instance SFoldable FreeIx where
sfoldMap f (FreeIx k) = k f
instance SPointed FreeIx where
slift m = FreeIx $ \k -> k m
instance SMonad FreeIx where
sbind = sfoldMap
instance SMonad FreeIx
instance
( Silo f
, Monad m
Expand Down
3 changes: 1 addition & 2 deletions src/Control/Monad/Trans/Indexed/Free/Lance.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ instance SFoldable FreeIx where
sfoldMap f (FreeIx wrapped) = sfoldMap (foldLance f) wrapped
instance SPointed FreeIx where
slift = FreeIx . slift . liftLance
instance SMonad FreeIx where
sbind = sfoldMap
instance SMonad FreeIx
instance (i ~ j, Monad m) => Applicative (FreeIx f i j m) where
pure = FreeIx . Wrap.FreeIx . return . Wrap.Unwrap
(<*>) = ixAp
Expand Down
3 changes: 1 addition & 2 deletions src/Control/Monad/Trans/Indexed/Free/Wrap.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ instance SFoldable FreeIx where
sfoldMap f (FreeIx m) = ixBind (sfoldMap f) (lift m)
instance SPointed FreeIx where
slift = FreeIx . return . slift
instance SMonad FreeIx where
sbind = sfoldMap
instance SMonad FreeIx
instance (Silo f, Monad m)
=> Functor (FreeIx f i j m) where
fmap f (FreeIx m) = FreeIx $ fmap (fmap f) m
Expand Down

0 comments on commit 156b02b

Please sign in to comment.