[Haskell-cafe] version of findIndex that works with a monadic predicate

2010-11-26 Thread José Romildo Malaquias
Hello. I need a function findIndexM, similar to findIndex from the standard module Data.List, but which works with a monadic predicate to test list elements. findIndex :: (a - Bool) - [a] - Maybe Int findIndexM :: (Monad m, Num a) = (t - m Bool) - [t] - m (Maybe a) findIndexM p xs = go 0 xs

Re: [Haskell-cafe] version of findIndex that works with a monadic predicate

2010-11-26 Thread Miguel Mitrofanov
findIndexM = (liftM (findIndex id) .) . mapM On 26 Nov 2010, at 22:46, José Romildo Malaquias wrote: Hello. I need a function findIndexM, similar to findIndex from the standard module Data.List, but which works with a monadic predicate to test list elements. findIndex :: (a - Bool) -