I find many things that I combine on my own, which seem to be generally useful, actually have a standard implementation that I simply did not know about, so it was curious if anyone could say that they had seen such a thing before:
It takes a monadic function and will add it until the predicate is chosen as an alternative, and then returns the result of the predicate:
until :: (Monad m, Alternative m) => (a -> ma) -> (a -> mc) -> a -> mc f `until` p = \a -> (f >=> (p `altF` (until fp))) a where f1 `altF` f2 = \a -> f1 a <|> f2 a
I understand that this is a clash with the prelude, I will probably call it something else, but I thought that at first I would see if there is similar functionality in the standard library, which I just donβt know about.
It also seems to me that I wonder if the compositional alternative that I wrote is defined elsewhere, or if any of these bits of functionality seem erroneous to start with. But the essence of my question is whether it is implemented elsewhere or something very similar is implemented elsewhere, perhaps
source share