[Haskell-cafe] Feeding a monad into itself
jake.waksbaum at gmail.com
Thu Jul 20 17:26:17 UTC 2017
I have a function f :: a -> Maybe a that I want to feed into itself with
some initial input until it returns Nothing.
untilNothing :: (a -> Maybe a) -> a -> a
untilNothing f x = case f x of
Just x' -> untilNothing f x'
Nothing -> x
Is there a better way to do this? I feel like there is something more
general going on with Monads being fed into themselves, but maybe I'm
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe