Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Notable changes to this project are documented in this file. The format is based
Breaking changes:

New features:
- Add Semigroup and Monoid instances (#51 by @PureFunctor)

Bugfixes:

Expand Down
7 changes: 7 additions & 0 deletions src/Control/Monad/ST/Internal.purs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module Control.Monad.ST.Internal

import Prelude

import Control.Apply (lift2)
import Control.Monad.Rec.Class (class MonadRec, Step(..))
import Partial.Unsafe (unsafePartial)

Expand Down Expand Up @@ -72,6 +73,12 @@ instance monadRecST :: MonadRec (ST r) where
Loop _ -> true
_ -> false

instance semigroupST :: Semigroup a => Semigroup (ST r a) where
append = lift2 append

instance monoidST :: Monoid a => Monoid (ST r a) where
mempty = pure mempty

-- | Run an `ST` computation.
-- |
-- | Note: the type of `run` uses a rank-2 type to constrain the phantom
Expand Down