
7 Mar
2016
7 Mar
'16
6:29 a.m.
You can define a mixture of takeWhile and sequence as: takeWhileM :: (a -> Bool) -> [IO a] -> IO [a] takeWhileM _ [] = return [] takeWhileM p (x:xs) = do e <- x if p e then do xs' <- takeWhileM p xs return (e : xs') else return [] and then write: ghci> takeWhileM (/="") (repeat getLine) >>= print asdf asdf ["asdf","asdf"] Yours, Anton Felix Lorenzen