Proposal: add fromRight and fromLeft to Data.Either

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
30 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Proposal: add fromRight and fromLeft to Data.Either

Anton Felix Lorenzen
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
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

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

Evan Laforge
I wouldn't want to encourage partial functions without even an error message.  Usually with Either you'll want to use the unexpected value in the error msg, e.g 'either (error . ("xyz: "++) . show) id'.

On Fri, May 20, 2016 at 1:08 PM, Anton Felix Lorenzen <[hidden email]> 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
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

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

David Feuer
In reply to this post by Anton Felix Lorenzen

-1. I don't want to encourage this sort of bad coding practice practice either. Keeping it inconvenient is fine by me.

On May 20, 2016 4:08 PM, "Anton Felix Lorenzen" <[hidden email]> 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
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

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

Dan Burton
I wouldn't mind something like this being available... but only if prefixed with the word "unsafe" or "partial" or other such scary words.

-- Dan Burton

On Fri, May 20, 2016 at 1:34 PM, David Feuer <[hidden email]> wrote:

-1. I don't want to encourage this sort of bad coding practice practice either. Keeping it inconvenient is fine by me.

On May 20, 2016 4:08 PM, "Anton Felix Lorenzen" <[hidden email]> 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
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries



_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

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

Kosyrev Serge
Dan Burton <[hidden email]> writes:
> I wouldn't mind something like this being available... but only if
> prefixed with the word "unsafe" or "partial" or other such scary
> words.

Heh, `unsafePerformLeft` / `unsafePerformRight` ? : -)

--
с уважениeм / respectfully,
Косырев Сергей
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

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

Theodore Lief Gannon
js :: a -> (Void, a)
js x = (undefined, x)

left :: (Void, Either a b) -> a
left (_, Left x) = x

There we go... now it looks truly terrifying:

left.js $(myValue)


(Apologies to Kosyrev for the double-send. Especially since that version was broken.)

On Fri, May 20, 2016 at 2:36 PM, Kosyrev Serge <[hidden email]> wrote:
Dan Burton <[hidden email]> writes:
> I wouldn't mind something like this being available... but only if
> prefixed with the word "unsafe" or "partial" or other such scary
> words.

Heh, `unsafePerformLeft` / `unsafePerformRight` ? : -)

--
с уважениeм / respectfully,
Косырев Сергей
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

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

Francesco Ariis
In reply to this post by Anton Felix Lorenzen
On Fri, May 20, 2016 at 10:08:40PM +0200, 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

Sometimes my lazy inner-self is guilty of longing for `fromRight` when
typing:

    λ> either undefined id xyz

but then again, importing Data.Either wouldn't make thing any shorter :P

    λ> :m +Da<tab>.Ei<tab>
    λ> fromRight zyx


I can see fromRight being useful in one-off script; anything bigger than
a few lines is asking for trouble!

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

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

amindfv
There's also (\(Right x)->x), which is pretty short and will give you a warning about the missing case.

(I could go either way on adding fromLeft/Right though)

Tom


> El 20 may 2016, a las 19:22, Francesco Ariis <[hidden email]> escribió:
>
>> On Fri, May 20, 2016 at 10:08:40PM +0200, 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
>
> Sometimes my lazy inner-self is guilty of longing for `fromRight` when
> typing:
>
>    λ> either undefined id xyz
>
> but then again, importing Data.Either wouldn't make thing any shorter :P
>
>    λ> :m +Da<tab>.Ei<tab>
>    λ> fromRight zyx
>
>
> I can see fromRight being useful in one-off script; anything bigger than
> a few lines is asking for trouble!
>
> _______________________________________________
> Libraries mailing list
> [hidden email]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

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

Edward Kmett-2
In reply to this post by Anton Felix Lorenzen
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 <[hidden email]> 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
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

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

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" <[hidden email]> 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 <[hidden email]> 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
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

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

Christopher Allen
I think Edward meant fromJust given the context.

Sent from my iPhone

On May 21, 2016, at 6:58 AM, David Feuer <[hidden email]> 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" <[hidden email]> 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 <[hidden email]> 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
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

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

David Feuer

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" <[hidden email]> wrote:
I think Edward meant fromJust given the context.

Sent from my iPhone

On May 21, 2016, at 6:58 AM, David Feuer <[hidden email]> 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" <[hidden email]> 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 <[hidden email]> 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
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

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

Edward Kmett-2
In reply to this post by David Feuer
Sorry, I meant fromJust.

On Sat, May 21, 2016 at 8:58 AM, David Feuer <[hidden email]> 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" <[hidden email]> 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 <[hidden email]> 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
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries



_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

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

Andreas Abel-2
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 <[hidden email]
> <mailto:[hidden email]>> 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" <[hidden email]
>     <mailto:[hidden email]>> 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
>         <[hidden email] <mailto:[hidden email]>> 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
>             [hidden email] <mailto:[hidden email]>
>             http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
>
>
>         _______________________________________________
>         Libraries mailing list
>         [hidden email] <mailto:[hidden email]>
>         http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
>
>
>
> _______________________________________________
> Libraries mailing list
> [hidden email]
> 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

[hidden email]
http://www2.tcs.ifi.lmu.de/~abel/
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

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

David Feuer

That's what I meant. Sorry; typing in my sleep!

On May 21, 2016 2:06 PM, "Andreas Abel" <[hidden email]> 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

  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 <a href="tel:21.05.2016%2015" value="+12105201615" target="_blank">21.05.2016 15:16, Edward Kmett wrote:
Sorry, I meant fromJust.

On Sat, May 21, 2016 at 8:58 AM, David Feuer <[hidden email]
<mailto:[hidden email]>> 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" <[hidden email]
    <mailto:[hidden email]>> 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
        <[hidden email] <mailto:[hidden email]>> 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
            [hidden email] <mailto:[hidden email]>
            http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries



        _______________________________________________
        Libraries mailing list
        [hidden email] <mailto:[hidden email]>
        http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries




_______________________________________________
Libraries mailing list
[hidden email]
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

[hidden email]
http://www2.tcs.ifi.lmu.de/~abel/

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

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

Dan Doel
In reply to this post by Edward Kmett-2
I would add (as I probably did last time something like this came up)
that it's difficult to get excited about all these functions named by
a systematic grammar, when we know _today_ how to just implement that
grammar as a library of composable pieces. And it has been implemented
in lens (and possibly other libraries that are subsets of lens).

Then you can have `is`, `over` (like map), `from` (take your pick on
whether it's partial or with-default), `foldOf`, `traverseOf`, ...,
and `_Left`, `_Right`, `_Just`, `_Nothing` (not all of these
correspond to lens; just you could define them). These building blocks
make all these functions definable, with almost exactly the names
they'd be given as one-off functions in several modules. But of
course, they also compose in more interesting ways, too. You can have
`from (_Left . _Just)`, but we will never be adding a
`fromLeftAndJust` function to base.

I don't really expect (or hope for) base to start pulling in big
chunks of lens. And maybe it makes sense for all of these to be in
base just for uniformity. But it also seems like people could just be
using something better.

-- Dan


On Sat, May 21, 2016 at 8:55 AM, Edward Kmett <[hidden email]> 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 <[hidden email]>
> 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
>> [hidden email]
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
>
>
> _______________________________________________
> Libraries mailing list
> [hidden email]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

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

Twan van Laarhoven
In reply to this post by Anton Felix Lorenzen
+1 from me.

I often use such functions when working in GHCi, and it is consistent with the
existence of fromJust. That said, I understand the opposition, and these
functions should never be used in production code.

Maybe we should put the lot of them (together with head, tail, fromJust) into a
"Partial" module?

Twan

On 2016-05-20 22:08, 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
> [hidden email]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

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

wren romano-2
In reply to this post by Andreas Abel-2
On Sat, May 21, 2016 at 2:06 PM, Andreas Abel <[hidden email]> 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
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

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

Michael Burge
+1 on the total versions.

On Sat, May 28, 2016 at 5:48 PM, wren romano <[hidden email]> wrote:
On Sat, May 21, 2016 at 2:06 PM, Andreas Abel <[hidden email]> 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
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

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

Edward Kmett-2
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 <[hidden email]> wrote:
+1 on the total versions.

On Sat, May 28, 2016 at 5:48 PM, wren romano <[hidden email]> wrote:
On Sat, May 21, 2016 at 2:06 PM, Andreas Abel <[hidden email]> 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
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries



_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
12