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 default many/some implementations via MonadPlus? #567

Closed
neongreen-sc opened this issue Aug 28, 2024 · 1 comment · Fixed by #570
Closed

Provide default many/some implementations via MonadPlus? #567

neongreen-sc opened this issue Aug 28, 2024 · 1 comment · Fixed by #570

Comments

@neongreen-sc
Copy link

neongreen-sc commented Aug 28, 2024

I understand that according to #163, the implementations of some and many from Alternative are slower than the MonadPlus implementations.

But does anything prevent us from doing this?

instance (Ord e, Stream s) => Alternative (ParsecT e s m) where
  empty = mzero
  (<|>) = mplus
  some = Control.Monad.Combinators.some
  many = Control.Monad.Combinators.many

This way the user would always get the fastest some and many implementations regardless of whether they follow the advice to use Control.Monad.Combinators or not. Am I missing something?

@mrkkrp
Copy link
Owner

mrkkrp commented Sep 3, 2024

As long as this compiles and passes the test suite I'm happy to merge it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants