[Haskell-cafe] Best way to return Bool based on a successful pattern match?

Nikolay Amiantov ab at fmap.me
Mon Jul 13 13:04:50 UTC 2015

Yes, for standard data types like Either or Maybe the best way is to use
library-defined functions -- I was more interested in a way to check for
any given pattern, which would look nicer than a custom defined function
or a LambdaCase. An example use case:

partition (\case MyPat -> True; _ -> False)

Anyway using lens for this is already very readable and concise, albeit
needs makePrisms/Lens and stuff.

On 07/13/2015 03:02 PM, Nikita Karetnikov wrote:
> Looking at the instances defined for Bool and Either, I don't think
> there's a higher level way of doing it.  But even if there's one, it'll
> probably be more obscure than isLeft, which is in base since


More information about the Haskell-Cafe mailing list