mirror of
https://github.com/lexi-lambda/freer-simple.git
synced 2024-12-25 15:14:29 +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
|
tell o = send $ Writer o
|
||||||
|
|
||||||
-- | Simple handler for Writer effects
|
-- | Simple handler for Writer effects
|
||||||
runWriter :: Eff (Writer o ': r) a -> Eff r (a,[o])
|
runWriter :: Monoid o => Eff (Writer o ': r) a -> Eff r (a,o)
|
||||||
runWriter = handleRelay (\x -> return (x,[]))
|
runWriter = handleRelay (\x -> return (x,mempty))
|
||||||
(\ (Writer o) k -> k () >>= \ (x,l) -> return (x,o:l))
|
(\ (Writer o) k -> k () >>= \ (x,l) -> return (x,o `mappend` l))
|
||||||
|
Loading…
Reference in New Issue
Block a user