mirror of
https://github.com/lexi-lambda/freer-simple.git
synced 2024-12-23 22:23:27 +03:00
Made writer work with arbitrary Monoids, not just lists
This commit is contained in:
parent
86a8212cd8
commit
0846542b7d
@ -35,6 +35,6 @@ tell :: Member (Writer o) r => o -> Eff r ()
|
||||
tell o = send $ Writer o
|
||||
|
||||
-- | Simple handler for Writer effects
|
||||
runWriter :: Eff (Writer o ': r) a -> Eff r (a,[o])
|
||||
runWriter = handleRelay (\x -> return (x,[]))
|
||||
(\ (Writer o) k -> k () >>= \ (x,l) -> return (x,o:l))
|
||||
runWriter :: Monoid o => Eff (Writer o ': r) a -> Eff r (a,o)
|
||||
runWriter = handleRelay (\x -> return (x,mempty))
|
||||
(\ (Writer o) k -> k () >>= \ (x,l) -> return (x,o `mappend` l))
|
||||
|
Loading…
Reference in New Issue
Block a user