universum
universum copied to clipboard
Add 'whenLeft_' and 'whenLeftM_' (and same for '*Right*')
Currently whenLeft has this type:
whenLeft :: Applicative f => Either l r -> (l -> f ()) -> f ()
I propose to rename whenLeft to whenLeft_ and add the following whenLeft:
whenLeft :: Applicative f => Either l r -> (l -> f r) -> f r
This might be useful when you want to throw exception on Left constructor, like this:
foo = do
result <- decodeFile "path/to/config/file"
config <- whenLeft result throwIO
...
Also consider doing the same for whenJust. Relates to #150.