Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'whenLeft_' and 'whenLeftM_' (and same for '*Right*') #172

Open
chshersh opened this issue May 24, 2018 · 0 comments
Open

Add 'whenLeft_' and 'whenLeftM_' (and same for '*Right*') #172

chshersh opened this issue May 24, 2018 · 0 comments
Labels
feature request type:breaking Breaking change (removal, renaming, semantic change, etc.) type:feature Something new is added.
Milestone

Comments

@chshersh
Copy link
Contributor

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.

@gromakovsky gromakovsky added the type:feature Something new is added. label Aug 7, 2018
@dcastro dcastro added the type:breaking Breaking change (removal, renaming, semantic change, etc.) label Jul 6, 2022
@dcastro dcastro added this to the v.1.9.0 milestone Jul 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request type:breaking Breaking change (removal, renaming, semantic change, etc.) type:feature Something new is added.
Projects
None yet
Development

No branches or pull requests

3 participants