fsprojects / FSharpx.Extras

Functional programming and other utilities from the original "fsharpx" project
https://fsprojects.github.io/FSharpx.Extras/
The Unlicense
682 stars 146 forks source link

Add named versions of the standard F#x operators #52

Open forki opened 12 years ago

forki commented 12 years ago

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.

panesofglass commented 12 years ago

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.

mausch commented 12 years ago

@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

7sharp9 commented 11 years ago

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.

mausch commented 11 years ago

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

7sharp9 commented 11 years ago

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

7sharp9 commented 11 years ago

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

7sharp9 commented 11 years ago

@mausch theres also (>>.)

If you include the ones in the Nullable module:

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

mausch commented 11 years ago

@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 commented 11 years ago

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 :)

panesofglass commented 9 years ago

:+1: for *Back.