FSharpx.Extras icon indicating copy to clipboard operation
FSharpx.Extras copied to clipboard

Add named versions of the standard F#x operators

Open forki opened this issue 13 years ago • 10 comments

We have a lot of cool operators in F#x. Let's try to give them names and add the named vbersions to the prelude (or the monads).

Pull request are welcome on this issue.

forki avatar Mar 30 '12 10:03 forki

I agree. I wonder if this couldn't be done in conjunction with finishing the pull request for type classes? We really should finish that one out.

panesofglass avatar Mar 30 '12 13:03 panesofglass

@panesofglass It's nagging me too, but I think they're independent issues... BTW I agree with this too. It's more than just a convenience, it's a necessity in the current design because we can only have one set of operators open at a time (i.e. >=> only for one monad). This is not the case with Gustavo's fork because it actually overloads the operators. We already have <!> map, <*> ap, >>= bind. Missing (with tentative names): =<< bindl, >=> kleislir, <=< kleislil, *> apr, <* apl, >> combine

mausch avatar Mar 30 '12 14:03 mausch

I almost never use symbolics as I like to have the option of intellisense. When you come back to code you have written previously its really annoying to not be able to see the function signature of the symbolics. Or having to alias the symbolic back to a named function so you can.

7sharp9 avatar Nov 30 '12 20:11 7sharp9

@7sharp9 Do you agree with the tentative names I proposed? Are there any other operators I didn't include?

mausch avatar Nov 30 '12 20:11 mausch

@mausch I think so, they seen sensible to me.

7sharp9 avatar Nov 30 '12 20:11 7sharp9

@mausch I know they wont be as pretty as infix symbolics, its a pity we don't have infix function declarations.

7sharp9 avatar Nov 30 '12 20:11 7sharp9

@mausch theres also (>>.)

If you include the ones in the Nullable module:

(+?), (-?), ( *?), (/?), (>?), (>=?), (<?), (<=?)

7sharp9 avatar Nov 30 '12 20:11 7sharp9

@7sharp9 >>. is actually combine, I forgot the dot in that message, as >> is obviously the built-in composition operator.

About the Nullable module, since F# 3.0 already has operators around Nullable and they're much better than the ones in this module, these operators are pretty much deprecated. I'll remove them when we upgrade to FSharp.Core 4.3 / 2.3

mausch avatar Nov 30 '12 20:11 mausch

Revisiting this issue, I'm having second thoughts about those names... here are some other suggestions:

=<< bindBack (which fits with List.foldBack, scanBack, etc) or =<< bindLeft

>=> kleisli and <=< kleisliBack or kleisliLeft

*> apRight and <* apLeft

So yeah, bikeshedding :)

mausch avatar Nov 30 '12 20:11 mausch

:+1: for *Back.

panesofglass avatar Oct 27 '14 18:10 panesofglass