Skip to content

Instantly share code, notes, and snippets.

@DanielG
Created September 15, 2012 10:10
Show Gist options
  • Select an option

  • Save DanielG/3727243 to your computer and use it in GitHub Desktop.

Select an option

Save DanielG/3727243 to your computer and use it in GitHub Desktop.
(for use with infinite lists)
consM x xs = do x' <- x; return [x'] <> xs
mapWhileM f c (a:as) = do
r <- f a
if c r == True
then return r `consM` (mapWhileM f c as)
else return []
instance Monoid (IO [String]) where
mempty = return []
a `mappend` b = do x <- a; y <- b; return (x++y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment