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 a BindLeft type class #12

Open
natefaubion opened this issue Jan 27, 2018 · 5 comments
Open

Add a BindLeft type class #12

natefaubion opened this issue Jan 27, 2018 · 5 comments
Labels
type: enhancement A new feature or addition.

Comments

@natefaubion
Copy link

class BindLeft m where
  lbind :: forall a b r. m a r -> (a -> m b r) -> m b r

class (Biapplicative m, BindLeft m) <= MonadLeft m

This is a generalized, type-changing catch operation, which is useful for things like Either, and also lets you implement a Monad instance for Flip.

@JordanMartinez
Copy link
Contributor

Wouldn't you also need to define an ApplyLeft and ApplicativeLeft to enable Flip to have a MonadLeft instance?

@natefaubion
Copy link
Author

@JordanMartinez Yes, my formulation above is incorrect. Biapplicative isn't appropriate for this.

@JordanMartinez JordanMartinez added the type: enhancement A new feature or addition. label Dec 4, 2021
@mikesol
Copy link

mikesol commented Dec 9, 2022

Ran across this today as I was looking for a bindLeft in a project. Would be useful!

@JordanMartinez
Copy link
Contributor

Maybe this would be better moved to the 'qualified do' package?

@garyb
Copy link
Member

garyb commented Dec 14, 2022

I don't think it necessarily needs qualified do to be useful, just the existence of the operation at all would be good! But it might also be good to provide a qualified do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A new feature or addition.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants