Closed turion closed 3 years ago
I would merge a PR adding that.
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?
Indeed, perhaps that's the reason there is no applicative version.
Ok I guess I'll close then until I have a better idea on what we could do.
The definitions in
Control.Monad.Combinators.Expr
are the only ones that don't exist as anAlternative
version. Is it possible to create those as well?