
13 Jul
2015
13 Jul
'15
9:04 a.m.
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 4.7.0.0.
-- Nikolay.