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

Add alias of 'result' #325

Open
cmeeren opened this issue May 21, 2020 · 5 comments
Open

Add alias of 'result' #325

cmeeren opened this issue May 21, 2020 · 5 comments
Labels

Comments

@cmeeren
Copy link
Contributor

cmeeren commented May 21, 2020

I use both FSharpPlus and FsToolkit.ErrorHandling in all my projects. The latter defines a result builder, which conflicts with the result operator from FSharpPlus. AFAIK there are other standard names for the result operator (not entirely sure – pure? retn?). I suggest FSharpPlus adds one or more of these standard aliases for result.

@wallymathieu
Copy link
Member

You could add your own operator in your own code by noting that the result operator is simply:

/// Lifts a value into a Functor. Same as return in Computation Expressions.
let inline result (x: 'T) : '``Functor<'T>`` = Return.Invoke x

@cmeeren
Copy link
Contributor Author

cmeeren commented May 21, 2020

Yep, I have, I just figured that it'd be nice to have in FSharpPlus too, since both FSharpPlus and FsToolkit.ErrorHandling are very useful libraries that work nicely together.

@gusty
Copy link
Member

gusty commented May 23, 2020

Just to add more information, pure is unfortunately a reserved word in F#, retn is an abbreviation and abbreviations are not encouraged in the F# guidelines.

I think we could add a unary operator but not sure which.

@cmeeren
Copy link
Contributor Author

cmeeren commented May 23, 2020

I think we could add a unary operator but not sure which.

But that doesn't work well with piping, right? E.g. instead of

a |> b |> c |> result

you would have to write

<op>(a |> b |> c)

right?

In any case, I get the point about abbreviations, though I think it can work if the abbreviation is clear and if it is for a good reason (e.g. to avoid a reserved keyword).

@gusty
Copy link
Member

gusty commented May 23, 2020

I would rather say:

you would have to write:

a |> b |> c |> (op)

Any suggestions for either operator or abbreviation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants