Skip to content

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

@thomashoneyman

Description

@thomashoneyman

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions