From 772ed217597e05ba35cddf67e888922fcefb9353 Mon Sep 17 00:00:00 2001 From: Justin Garcia Date: Sun, 28 Aug 2022 10:08:14 +0800 Subject: [PATCH 1/2] Add Semigroup and Monoid instances --- src/Control/Monad/ST/Internal.purs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Control/Monad/ST/Internal.purs b/src/Control/Monad/ST/Internal.purs index a467276..a0c4dcf 100644 --- a/src/Control/Monad/ST/Internal.purs +++ b/src/Control/Monad/ST/Internal.purs @@ -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) @@ -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 From ed1ba864718cf8f77868f6aab0e7084438428535 Mon Sep 17 00:00:00 2001 From: Justin Garcia Date: Sun, 28 Aug 2022 10:10:44 +0800 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3619c80..dacf413 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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: