Skip to content

simplify the distribute Return case #122

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mauke
Copy link

@mauke mauke commented Jul 4, 2023

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
Copy link
Contributor

treeowl commented Jul 4, 2023

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

@mauke
Copy link
Author

mauke commented Jul 4, 2023

Can I do that from the github web UI?

@treeowl
Copy link
Contributor

treeowl commented Jul 4, 2023

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.

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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants