haskell-streaming / streaming

An optimized general monad transformer for streaming applications, with a simple prelude of functions
BSD 3-Clause "New" or "Revised" License
157 stars 30 forks source link

simplify the distribute Return case #122

Open mauke opened 1 year ago

mauke commented 1 year ago

This commit shouldn't change the meaning of the code:

lift (Return r) =
 -- by Monad instance of Stream
lift (return r) =
 -- by laws of MonadTrans/lift
return r 

However, the result may be more efficient. In the case where t = Stream f, we have:

lift (Return r) =
 -- by definition of lift
(Effect . fmap Return) (Return r) =
 -- by definition of (.)
Effect (fmap Return (Return r)) =
 -- by definition of fmap
Effect (Return (Return r))

But doing return r directly produces just Return r (without the no-op Effect wrapper).

treeowl commented 1 year ago

We just (hopefully) made CI work. Could you try rebasing and force pushing?

mauke commented 1 year ago

Can I do that from the github web UI?

treeowl commented 1 year ago

Never mind; it looks like the new CI is broken. I'll try to look at it all in a bit. Your PR looks very reasonable, and I assume it's correct, but I want to make sure CI doesn't turn up some subtle laziness issue.