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

Monad constraint on f is unnecessarily powerful in many functions #42

Closed
thomashoneyman opened this issue Sep 30, 2020 · 0 comments · Fixed by #43
Closed

Monad constraint on f is unnecessarily powerful in many functions #42

thomashoneyman opened this issue Sep 30, 2020 · 0 comments · Fixed by #43

Comments

@thomashoneyman
Copy link
Contributor

thomashoneyman commented Sep 30, 2020

Several functions in the library require a Monad f constraint where the constraint is unnecessary:

-- | Execute (unroll) a single step on a machine.
stepMealy :: forall f s a. (Monad f) => s -> MealyT f s a -> f (Step f s a)
stepMealy = flip runMealyT

take :: forall f s a. (Monad f) => Int -> MealyT f s a -> MealyT f s a
take n m = if n <= 0 then halt
else mealy $ \s -> f <$> stepMealy s m
where f Halt = Halt
f (Emit a m') = Emit a (take (n - 1) m')

For some of these there is no constraint necessary, and for others something weaker like Applicative would do; perhaps due to functions used internally these really do eventually need the constraint and so it's here for convenience, but if not we could relax them.

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

Successfully merging a pull request may close this issue.

1 participant