isLeft/isRight (Was: leftToMaybe/rightToMaybe)

Jon Fairbairn jon.fairbairn at cl.cam.ac.uk
Thu Aug 8 11:09:35 CEST 2013


Erik de Castro Lopo <mle+hs at mega-nerd.com> writes:

> Henning Thielemann wrote:
>
>> http://www.haskell.org/pipermail/libraries/2012-November/018709.html
>> http://www.haskell.org/pipermail/libraries/2012-December/018716.html
>
> Henning,
>
> In the second link above you wrote:
>
>> It would be a good opportunity to check how these packages use isLeft and 
>> isRight. E.g. if they use them in connection with fromLeft and fromRight 
>> then this would be an argument for me to exclude isLeft and isRight as 
>> well.
>
> My main usage of isLeft/isRight is in HSpec tests where I write:
>
>
>      value1 `shouldSatisfy' isLeft
>      value2 `shouldSatisfy' isRight


What I don’t like about this is that isLeft strikes me as having
too little mnemonic information in it. While there’s an argument
that if one uses “(const True ||| const False)” many times in a
programme one might usefully name it, the most suitable name
surely depends on the programme. What is the /intention/ of
isLeft in the above tests, and can you not name it to reflect
that? I’ll grant that for some programmes isLeft may be as good
a name as can be found, but I doubt it in general.

-- 
Jón Fairbairn                                 Jon.Fairbairn at cl.cam.ac.uk






More information about the Libraries mailing list