Re: Proposal: add fromRight and fromLeft to Data.Either

No one wants to remove fromMaybe. In fact, it could serve as a template for
total fromLeft and fromRight:
fromLeft :: b -> (a -> b) -> Either a x -> b
fromRight :: b -> (a -> b) -> Either x a -> b
On May 21, 2016 8:55 AM, "Edward Kmett"
When working with Either, I am often missing two simple functions: fromRight :: Either a b -> b fromLeft :: Either a b -> a
It has been implemented a couple of times: http://hayoo.fh-wedel.de/?query=fromRight
But I don't want to depend on yet another library for such a basic function.
Could it be added?
Anton _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

I think Edward meant fromJust given the context. Sent from my iPhone
On May 21, 2016, at 6:58 AM, David Feuer
wrote: No one wants to remove fromMaybe. In fact, it could serve as a template for total fromLeft and fromRight:
fromLeft :: b -> (a -> b) -> Either a x -> b fromRight :: b -> (a -> b) -> Either x a -> b
On May 21, 2016 8:55 AM, "Edward Kmett"
wrote: I'm personally -1 on this. A large portion of the community is vehemently against adding new partial functions, and they have to share base with the rest of us. I'd say more people want to remove fromMaybe, head, tail, etc. than want to double down on the pattern at this time.
-Edward
On Fri, May 20, 2016 at 4:08 PM, Anton Felix Lorenzen
wrote: When working with Either, I am often missing two simple functions: fromRight :: Either a b -> b fromLeft :: Either a b -> a It has been implemented a couple of times: http://hayoo.fh-wedel.de/?query=fromRight
But I don't want to depend on yet another library for such a basic function.
Could it be added?
Anton _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

I'm sure he did, but I figured I should take the opportunity to point out
other ways to use those names.
On May 21, 2016 9:09 AM, "Christopher Allen"
I think Edward meant fromJust given the context.
Sent from my iPhone
On May 21, 2016, at 6:58 AM, David Feuer
wrote: No one wants to remove fromMaybe. In fact, it could serve as a template for total fromLeft and fromRight:
fromLeft :: b -> (a -> b) -> Either a x -> b fromRight :: b -> (a -> b) -> Either x a -> b On May 21, 2016 8:55 AM, "Edward Kmett"
wrote: I'm personally -1 on this.
A large portion of the community is vehemently against adding new partial functions, and they have to share base with the rest of us. I'd say more people want to remove fromMaybe, head, tail, etc. than want to double down on the pattern at this time.
-Edward
On Fri, May 20, 2016 at 4:08 PM, Anton Felix Lorenzen
wrote: When working with Either, I am often missing two simple functions: fromRight :: Either a b -> b fromLeft :: Either a b -> a
It has been implemented a couple of times: http://hayoo.fh-wedel.de/?query=fromRight
But I don't want to depend on yet another library for such a basic function.
Could it be added?
Anton _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

Sorry, I meant fromJust.
On Sat, May 21, 2016 at 8:58 AM, David Feuer
No one wants to remove fromMaybe. In fact, it could serve as a template for total fromLeft and fromRight:
fromLeft :: b -> (a -> b) -> Either a x -> b fromRight :: b -> (a -> b) -> Either x a -> b On May 21, 2016 8:55 AM, "Edward Kmett"
wrote: I'm personally -1 on this.
A large portion of the community is vehemently against adding new partial functions, and they have to share base with the rest of us. I'd say more people want to remove fromMaybe, head, tail, etc. than want to double down on the pattern at this time.
-Edward
On Fri, May 20, 2016 at 4:08 PM, Anton Felix Lorenzen
wrote: When working with Either, I am often missing two simple functions: fromRight :: Either a b -> b fromLeft :: Either a b -> a
It has been implemented a couple of times: http://hayoo.fh-wedel.de/?query=fromRight
But I don't want to depend on yet another library for such a basic function.
Could it be added?
Anton _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

Ah, yes, we want fromLeft and fromRight, but with types fromLeft :: a -> Either a b -> a fromRight :: b -> Either a b -> b where the first argument is the "default", like fromLeft a (Right b) = a Then you can write fromLeft impossible e where `impossible` does a controlled crash of your program. (See fromMaybe.) --Andreas On 21.05.2016 15:16, Edward Kmett wrote:
Sorry, I meant fromJust.
On Sat, May 21, 2016 at 8:58 AM, David Feuer
mailto:david.feuer@gmail.com> wrote: No one wants to remove fromMaybe. In fact, it could serve as a template for total fromLeft and fromRight:
fromLeft :: b -> (a -> b) -> Either a x -> b fromRight :: b -> (a -> b) -> Either x a -> b
On May 21, 2016 8:55 AM, "Edward Kmett"
mailto:ekmett@gmail.com> wrote: I'm personally -1 on this.
A large portion of the community is vehemently against adding new partial functions, and they have to share base with the rest of us. I'd say more people want to remove fromMaybe, head, tail, etc. than want to double down on the pattern at this time.
-Edward
On Fri, May 20, 2016 at 4:08 PM, Anton Felix Lorenzen
mailto:anfelor@posteo.de> wrote: When working with Either, I am often missing two simple functions: fromRight :: Either a b -> b fromLeft :: Either a b -> a
It has been implemented a couple of times: http://hayoo.fh-wedel.de/?query=fromRight
But I don't want to depend on yet another library for such a basic function.
Could it be added?
Anton _______________________________________________ Libraries mailing list Libraries@haskell.org mailto:Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org mailto:Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
-- Andreas Abel <>< Du bist der geliebte Mensch. Department of Computer Science and Engineering Chalmers and Gothenburg University, Sweden andreas.abel@gu.se http://www2.tcs.ifi.lmu.de/~abel/

That's what I meant. Sorry; typing in my sleep!
On May 21, 2016 2:06 PM, "Andreas Abel"
Ah, yes, we want fromLeft and fromRight, but with types
fromLeft :: a -> Either a b -> a fromRight :: b -> Either a b -> b
where the first argument is the "default", like
fromLeft a (Right b) = a
Then you can write
fromLeft impossible e
where `impossible` does a controlled crash of your program. (See fromMaybe.)
--Andreas
On 21.05.2016 15:16, Edward Kmett wrote:
Sorry, I meant fromJust.
On Sat, May 21, 2016 at 8:58 AM, David Feuer
mailto:david.feuer@gmail.com> wrote: No one wants to remove fromMaybe. In fact, it could serve as a template for total fromLeft and fromRight:
fromLeft :: b -> (a -> b) -> Either a x -> b fromRight :: b -> (a -> b) -> Either x a -> b
On May 21, 2016 8:55 AM, "Edward Kmett"
mailto:ekmett@gmail.com> wrote: I'm personally -1 on this.
A large portion of the community is vehemently against adding new partial functions, and they have to share base with the rest of us. I'd say more people want to remove fromMaybe, head, tail, etc. than want to double down on the pattern at this time.
-Edward
On Fri, May 20, 2016 at 4:08 PM, Anton Felix Lorenzen
mailto:anfelor@posteo.de> wrote: When working with Either, I am often missing two simple functions: fromRight :: Either a b -> b fromLeft :: Either a b -> a
It has been implemented a couple of times: http://hayoo.fh-wedel.de/?query=fromRight
But I don't want to depend on yet another library for such a basic function.
Could it be added?
Anton _______________________________________________ Libraries mailing list Libraries@haskell.org mailto:Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org mailto:Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
-- Andreas Abel <>< Du bist der geliebte Mensch.
Department of Computer Science and Engineering Chalmers and Gothenburg University, Sweden
andreas.abel@gu.se http://www2.tcs.ifi.lmu.de/~abel/

On Sat, May 21, 2016 at 2:06 PM, Andreas Abel
Ah, yes, we want fromLeft and fromRight, but with types
fromLeft :: a -> Either a b -> a fromRight :: b -> Either a b -> b
where the first argument is the "default", like
If anything is added, then +1 for these versions. Very strong -1 for adding partial functions. -- Live well, ~wren

+1 on the total versions.
On Sat, May 28, 2016 at 5:48 PM, wren romano
On Sat, May 21, 2016 at 2:06 PM, Andreas Abel
wrote: Ah, yes, we want fromLeft and fromRight, but with types
fromLeft :: a -> Either a b -> a fromRight :: b -> Either a b -> b
where the first argument is the "default", like
If anything is added, then +1 for these versions.
Very strong -1 for adding partial functions.
-- Live well, ~wren _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

The main annoyance with the total versions is that the existing fromJust
has the wrong convention.
Oh well. Consistency is overrated.
-Edward
On Sun, May 29, 2016 at 9:00 PM, Michael Burge
+1 on the total versions.
On Sat, May 28, 2016 at 5:48 PM, wren romano
wrote: On Sat, May 21, 2016 at 2:06 PM, Andreas Abel
wrote: Ah, yes, we want fromLeft and fromRight, but with types
fromLeft :: a -> Either a b -> a fromRight :: b -> Either a b -> b
where the first argument is the "default", like
If anything is added, then +1 for these versions.
Very strong -1 for adding partial functions.
-- Live well, ~wren _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

On 30/05/16 03:40, Edward Kmett wrote:
The main annoyance with the total versions is that the existing fromJust has the wrong convention.
Oh well. Consistency is overrated.
So you don't mind the breaking change in the `either` package? For the lazy; `either` defines:
Data.Either.Combinators.fromLeft :: a -> Either a b -> a Data.Either.Combinators.fromLeft' :: Either a b -> a (~Right similarly)
Also, packages `MissingH` and `extra` define the consistent
fromLeft :: Either a b -> a
(don't know if user numbers of those count as significant in any way.) -1 on both partial and inconsistent total

On 30.05.2016 09:29, lennart spitzner wrote:
For the lazy; `either` defines:
Data.Either.Combinators.fromLeft :: a -> Either a b -> a
This is the thing we want. -- Andreas Abel <>< Du bist der geliebte Mensch. Department of Computer Science and Engineering Chalmers and Gothenburg University, Sweden andreas.abel@gu.se http://www2.tcs.ifi.lmu.de/~abel/

lennart spitzner
Data.Either.Combinators.fromLeft :: a -> Either a b -> a
This is the thing we want.
Oh indeed, derp; still had the first suggestion in mind. (b -> (a -> b) -> Either ..)
On this one i am neutral.
How should we address the part where we don't want to promote Partiality Oriented Programming? -- с уважениeм / respectfully, Косырев Сергей

-1 for partial. Indifferent on the total versions. `either (const _) id` is easy enough. On May 30, 2016 9:38 AM, "Kosyrev Serge" <_deepfire@feelingofgreen.ru> wrote:
lennart spitzner
writes: Data.Either.Combinators.fromLeft :: a -> Either a b -> a
This is the thing we want.
Oh indeed, derp; still had the first suggestion in mind. (b -> (a -> b) -> Either ..)
On this one i am neutral.
How should we address the part where we don't want to promote Partiality Oriented Programming?
-- с уважениeм / respectfully, Косырев Сергей _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

It is a minor annoyance, not a -1. The fromLeft and fromRight there got merged in from another package when we started consolidating. I've never really given them conscious thought, but on the plus side, I'd get to just re-export the combinators from base in Data.Either.Combinators avoiding conflicts. I'm a weak +1 on adding the total versions that Wren espoused above. -Edward On Mon, May 30, 2016 at 3:29 AM, lennart spitzner < lsp@informatik.uni-kiel.de> wrote:
On 30/05/16 03:40, Edward Kmett wrote:
The main annoyance with the total versions is that the existing fromJust has the wrong convention.
Oh well. Consistency is overrated.
So you don't mind the breaking change in the `either` package?
For the lazy; `either` defines:
Data.Either.Combinators.fromLeft :: a -> Either a b -> a Data.Either.Combinators.fromLeft' :: Either a b -> a (~Right similarly)
Also, packages `MissingH` and `extra` define the consistent
fromLeft :: Either a b -> a
(don't know if user numbers of those count as significant in any way.)
-1 on both partial and inconsistent total
participants (10)
-
Andreas Abel
-
Andreas Abel
-
Christopher Allen
-
David Feuer
-
Edward Kmett
-
evan@evan-borden.com
-
Kosyrev Serge
-
lennart spitzner
-
Michael Burge
-
wren romano