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

Provide Control.Applicative.Combinators.Expr #35

Closed
turion opened this issue Feb 16, 2021 · 4 comments
Closed

Provide Control.Applicative.Combinators.Expr #35

turion opened this issue Feb 16, 2021 · 4 comments

Comments

@turion
Copy link

turion commented Feb 16, 2021

The definitions in Control.Monad.Combinators.Expr are the only ones that don't exist as an Alternative version. Is it possible to create those as well?

@mrkkrp
Copy link
Owner

mrkkrp commented Feb 16, 2021

I would merge a PR adding that.

@turion
Copy link
Author

turion commented Feb 16, 2021

I read the source a bit closer:

addPrecLevel :: MonadPlus m => m a -> [Operator m a] -> m a
addPrecLevel term ops =
  term' >>= \x -> choice [ras' x, las' x, nas' x, tern' x, return x]
  where
    ...

It seems to me that this is a usage of >>= that can't be replicated only with Applicative, right? But requiring a constraint (Monad m, Alternative m) without MonadPlus m seems silly. So I guess it actually can't be done?

We could still try and reduce MonadPlus m usage here and there (e.g. pTerm only needs Alternative I believe), but I guess we can't get rid of it completely?

@mrkkrp
Copy link
Owner

mrkkrp commented Feb 17, 2021

Indeed, perhaps that's the reason there is no applicative version.

@turion
Copy link
Author

turion commented Feb 17, 2021

Ok I guess I'll close then until I have a better idea on what we could do.

@turion turion closed this as completed Feb 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants