Skip to content

Add subclasses to enforce the type class laws #126

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

Merged
merged 1 commit into from
Oct 15, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Control/Monad/Writer/Class.purs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Data.Tuple (Tuple(..))
-- | Law:
-- |
-- | - `do { tell x ; tell y } = tell (x <> y)`
class Monad m <= MonadTell w m | m -> w where
class (Semigroup w, Monad m) <= MonadTell w m | m -> w where
tell :: w -> m Unit

-- | An extension of the `MonadTell` class that introduces some operations on
Expand All @@ -33,7 +33,7 @@ class Monad m <= MonadTell w m | m -> w where
-- | - `do { tell x ; tell y } = tell (x <> y)`
-- | - `listen (pure a) = pure (Tuple a mempty)`
-- | - `listen (writer a x) = tell x $> Tuple a x`
class MonadTell w m <= MonadWriter w m | m -> w where
class (Monoid w, MonadTell w m) <= MonadWriter w m | m -> w where
listen :: forall a. m a -> m (Tuple a w)
pass :: forall a. m (Tuple a (w -> w)) -> m a

Expand Down