Currying error on the wrong side
See original GitHub issueThis story tracks back to the first release of F# where the function Async.Catch
was added, using the type on the left for the “right” value.
This in a type system with HKT support is the wrong decision, as we’re interested in currying types, then we want to have the good value on the rightmost position.
Now, in F# land we don’t have real HKTs so that’s not a technical restriction, just theorotical at the moment.
So, people started adopting it, then the new Result
type landed in F# and guess what? They did it again. Left type for the right type.
Now, people is asking for some Result
functions added to F# core. This is when the problem becomes a real problem, because here we’re not talking about types, we’re talking about actual values.
For values, it’s fair to think that’s also convenient to curry on the good one. See this comment from @kspeakman https://github.com/fsharp/fslang-suggestions/issues/526#issuecomment-393539604
Now the problem is we still don’t know what would be the standard for F# it’s probably a bit early. Here in F#+ we did the either
function with the error on the right, we can change it in V2 but now we’re about to ship bifoldables, so the question is do we want to swap the functions? If the answer is yes, we can still do it for v1.1 but not later.
Issue Analytics
- State:
- Created 4 years ago
- Comments:19 (17 by maintainers)
Top GitHub Comments
Sounds like the logical choice then is to document the weirdness and live with it. It’s a bit of an ugly remnant, but what to do.
Yes. But I would say this problem becomes important when writing generic code.
Let’s try to draft some consistency rules:
Bifoldable<'T1,'T2>
correspond toChoice<'T2,'T1>
andResult<'T2,'T1>
.Bifunctor
should follow the same rules, but we’re a bit late as that would be a breaking change. Indeed this reveals that ourbimap
forResult
is reversed, normally the first function maps on the Error.Bifunctor
andBifoldable
should be consistent as there are some rules involving both.ArrowChoice
is also affected, it looks like it is already reversed but I would say it needs to be reviewed.We’re a bit late now, either we:
Bifoldable
, it would be out of sync with other abstractions that will be corrected in v2.0Bifoldable
consistent with the existing abstractions. Eventually for v2.0 all will be swapped.Bifoldable
until v2.0 to avoid conflict.Bifoldable
but not the instances forEither
andChoice
which are the conflicting ones.Thoughts?