library of monadic functions [was: Why no findM ? simple Cat revisited]

Samuel Tardieu sam at
Wed Nov 12 00:31:04 EST 2003

Andrew J Bromage wrote:

> I can also make a case for:
>   findM'' :: (Monad m) => (a -> Bool) -> [m a] -> m a
>   findM'' p [] = fail "findM'': not found"
>   findM'' p (x:xs) = p x >>= \b -> if b then return x else findM'' p xs

The last line doesn't seem to compile. Don't you mean

findM'' p (x:xs) = x >>= \b -> if p b then return b else findM'' p xs



More information about the Haskell-Cafe mailing list