Skip to content
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

extend ComputationExpression builders with Map : m<'a> * ('a -> 'b) -> m<'b> #36

Closed
baronfel opened this issue Oct 20, 2016 · 6 comments

Comments

@baronfel
Copy link
Contributor

baronfel commented Oct 20, 2016

Submitted by Georg Haaser on 1/31/2016 12:00:00 AM
8 votes on UserVoice prior to migration

In many scenarios computation expressions could be executed way more efficiently when having just a little more information. The typical use-case for that would be something like

    async {
        let! a = something
        return 2*a
    }

which currently gets translated to:

    async.Bind(something, fun a -> async.Return(2*a))

By monad laws (borrowed from haskell here) this must be equal to:

    async.Map(something, fun a -> 2*a)

In many scenarios the latter can be implemented with a lot less overhead, so in my opinion it would be profitable to allow users to provide this "shortcut".

Original UserVoice Submission
Archived Uservoice Comments

@dsyme dsyme removed the open label Oct 29, 2016
@dsyme
Copy link
Collaborator

dsyme commented Mar 1, 2017

Going over old issues: just to say that I agree this is a reasonable suggestion.

@rmunn
Copy link

rmunn commented Nov 17, 2017

Just a note that the conversion from UserVoice glitched on this issue: the two occurrences of 2_a in the sample code should have both been 2*a. There's no special meaning attached to the underscore here; the intended sample code is just "multiply a by 2".

@dsyme
Copy link
Collaborator

dsyme commented Nov 17, 2017

@rmunn Thanks, fixed.

@Rickasaurus
Copy link

Yes please. This is partly why the continuation monad is so crazy expensive right?

@jwosty
Copy link
Contributor

jwosty commented Mar 14, 2018

@dsyme needs-rfc tag can be removed

@dsyme
Copy link
Collaborator

dsyme commented Sep 25, 2021

Was completed a while back

@dsyme dsyme closed this as completed Sep 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants