Gabriella439 / pipes

Compositional pipelines
BSD 3-Clause "New" or "Revised" License
487 stars 72 forks source link

Fix `pass` in `MonadWriter` instance #192

Closed ivan-timokhin closed 6 years ago

ivan-timokhin commented 6 years ago

Previous version would accumulate the entire log unchanged, and then append a modified version at the end; the new one removes the old log entries by replacing them with mempty.

Here's an example (any execWriter from mtl):

execWriter $ runEffect $ pass $ tell [1] >> pure ((), (2:))

Previously, this would evaluate to [1,2,1] (old log + modified old log); now, it evaluates to [2,1], same as when using just WriterT.

Gabriella439 commented 6 years ago

Ah, good catch! Yes, I agree that your version is the correct behavior

ivan-timokhin commented 6 years ago

No credit to me, I picked the idea from free.

Gabriella439 commented 6 years ago

This is now up on Hackage as pipes-4.3.6