You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
as typing either (const a) identity becomes old rather quickly and I need these functions much more frequently than their partial counterparts. I'm not sure how confusing it would be to define these functions differently in two modules in this package, but even if don't rename the old ones I think this would be a win.
Reacted by Gary Burgess, Sam A. Horvath-Hunt and Adrian Sieber
Agreed, and shouldn't the current fromLeft be unsafeFromLeft?
If the current type signature is swapped out for your type signature, how will this affect the results one sees when one searches for fromLeft via Pursuit? Will both versions of the same function appear?
I think it is a little unfortunate that doing this would introduce an inconsistency with maybe though, as fromJust is partial. It also departs from Haskell as well right?
Abbreviations are overrated imo, especially in cases like this where the function we are considering doesn’t have an existing agreed-upon name. We also have editor tooling to reduce the burden of typing it out. I’m not keen on eitherLeft.
I’d suggest not, unless we intend to keep them in the library. Updating fromLeft to fromLeft’ is, in practice, going to be pretty much equally arduous as updating it to fromLeft (crashWith “unexpected Right”), because the time consuming part is finding the files you need to change and checking that stuff still compiles after making the changes.
We could restore the Unsafe module like we had pre-Partial and move the Partial versions in there.
I don't see the PR getting merged until we have another reason to break the whole ecosystem (like a breaking compiler release), just so you know @JordanMartinez.
Activity
JordanMartinez commentedon Feb 15, 2019
Agreed, and shouldn't the current
fromLeftbeunsafeFromLeft?If the current type signature is swapped out for your type signature, how will this affect the results one sees when one searches for
fromLeftvia Pursuit? Will both versions of the same function appear?hdgarrood commentedon Feb 15, 2019
Pursuit only includes the latest version of each library in the search index, so only the new version would show up.
hdgarrood commentedon Feb 15, 2019
I’d advocate dropping the partial variant actually: you can easily recover it with
fromLeft (crashWith “whatever”)hdgarrood commentedon Feb 15, 2019
I think it is a little unfortunate that doing this would introduce an inconsistency with maybe though, as fromJust is partial. It also departs from Haskell as well right?
hdgarrood commentedon Feb 15, 2019
On reflection I’m a little less enthusiastic about this, given how low down in the ecosystem it is.
JordanMartinez commentedon Feb 15, 2019
That's what I thought after reading your comment.
What if the function was called something other than
fromLeft? For exampleeitherL default (\leftValue -> body) eitherand the same for
eitherR?hdgarrood commentedon Feb 15, 2019
fromLeftWithDefault maybe?
JordanMartinez commentedon Feb 15, 2019
I feel like that name is too long. What about
eitherLeftandeitherRight?hdgarrood commentedon Feb 15, 2019
Abbreviations are overrated imo, especially in cases like this where the function we are considering doesn’t have an existing agreed-upon name. We also have editor tooling to reduce the burden of typing it out. I’m not keen on eitherLeft.
JordanMartinez commentedon Feb 15, 2019
Hard to argue with those points, haha. I've been on the side where a terse function name left me confused about it for quite a while...
kritzcreek commentedon Feb 15, 2019
basehas them fwiw: http://hackage.haskell.org/package/base-4.12.0.0/docs/Data-Either.html#v:fromLefthdgarrood commentedon Feb 15, 2019
Oh! I wasn’t aware of that, that does change things actually. I’ll withdraw my objection then.
JordanMartinez commentedon Feb 16, 2019
To help with migration, should there be a
fromLeft'and vice versa for those who still want the Partial version of this function?hdgarrood commentedon Feb 17, 2019
I’d suggest not, unless we intend to keep them in the library. Updating
fromLefttofromLeft’is, in practice, going to be pretty much equally arduous as updating it tofromLeft (crashWith “unexpected Right”), because the time consuming part is finding the files you need to change and checking that stuff still compiles after making the changes.garyb commentedon Feb 17, 2019
We could restore the
Unsafemodule like we had pre-Partialand move thePartialversions in there.I don't see the PR getting merged until we have another reason to break the whole ecosystem (like a breaking compiler release), just so you know @JordanMartinez.
JordanMartinez commentedon Feb 19, 2019
Ok. Thanks for the heads up.
In my PR, should I also add the
Unsafemodule? If so, what should the functions be called?safareli commentedon Sep 23, 2019
Would like to know what you think on somewhat related topic purescript/purescript-maybe#44