Skip to content
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

Add a semigroup instance for CollSt #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 6 additions & 2 deletions src/Control/Monad/SD/STCLang.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Control.Monad.SD.Ohua
import Control.Monad.SD.Smap
import Data.Dynamic2
import Data.StateElement
import Data.Semigroup

import Control.DeepSeq (NFData)
import Control.Monad.State as S
Expand All @@ -19,10 +20,13 @@ data CollSt = CollSt
, signals :: [IO S]
}

instance Semigroup CollSt where
(CollSt st1 si1) <> (CollSt st2 si2) =
CollSt (st1 <> st2) (si1 <> si2)

instance Monoid CollSt where
mempty = CollSt [] []
CollSt st1 si1 `mappend` CollSt st2 si2 =
CollSt (st1 `mappend` st2) (si1 `mappend` si2)
mappend = (<>)

type STCLang a b = StateT CollSt IO (a -> OhuaM b)

Expand Down