generateA :: Applicative f => Int -> (Int -> f a) -> f (Vector a)
-- specification
generateA n f = sequenceA (generate n f)
The Monad m constraint on generateM seems to flow from unstreamM. unstreamM, in turn, absolutely requires a Monad m constraint because of the way general streams are structured. For generating vectors, this all seems a bit sad, since the exact shape of the result stream is known in advance (a specific number of Yields followed by Done). I don't know that there's any way around that annoyance.
The
Monad mconstraint ongenerateMseems to flow fromunstreamM.unstreamM, in turn, absolutely requires aMonad mconstraint because of the way general streams are structured. For generating vectors, this all seems a bit sad, since the exact shape of the result stream is known in advance (a specific number ofYields followed byDone). I don't know that there's any way around that annoyance.