-
Notifications
You must be signed in to change notification settings - Fork 15
Monoid instance for FreeT #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,9 @@ import Prelude | |
import Data.Bifunctor (bimap) | ||
import Data.Either (Either(..)) | ||
import Data.Exists (Exists, mkExists, runExists) | ||
import Data.Monoid (class Monoid, mempty) | ||
|
||
import Control.Apply (lift2) | ||
import Control.Monad.Rec.Class (class MonadRec, Step(..), tailRecM) | ||
import Control.Monad.Trans.Class (class MonadTrans) | ||
|
||
|
@@ -76,6 +78,12 @@ instance monadRecFreeT :: (Functor f, Monad m) => MonadRec (FreeT f m) where | |
Loop s1 -> go s1 | ||
Done a -> pure a | ||
|
||
instance semigroupFreeT :: (Functor f, Monad m, Semigroup w) => Semigroup (FreeT f m w) where | ||
append = lift2 append | ||
|
||
instance monoidFreeT :: (Functor f, Monad m, Monoid w) => Monoid (FreeT f m w) where | ||
mempty = pure mempty | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Likewise you only need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually I'm not sure about that - FreeT's |
||
|
||
-- | Lift an action from the functor `f` to a `FreeT` action. | ||
liftFreeT :: forall f m a. (Functor f, Monad m) => f a -> FreeT f m a | ||
liftFreeT fa = FreeT \_ -> pure (Right (map pure fa)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.