Made writer work with arbitrary Monoids, not just lists

This commit is contained in:
ElvishJerricco 2016-03-02 05:51:23 -05:00
parent 86a8212cd8
commit 0846542b7d

View File

@ -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))