Skip to content

Instantly share code, notes, and snippets.

@dtchepak
Created October 4, 2012 00:54
Show Gist options
  • Save dtchepak/3830874 to your computer and use it in GitHub Desktop.
Save dtchepak/3830874 to your computer and use it in GitHub Desktop.
runKoan :: Koan -> IO Bool
runUntilFail :: [Koan] -> IO ()
runUntilFail [] = return ()
runUntilFail (x:xs) = do
continue <- runKoan x
when continue $ runUntilFail xs
@tonymorris
Copy link

import Control.Monad

takeWhileM_ ::
  Monad m =>
  (a -> m Bool) 
  -> [a]
  -> m ()
takeWhileM_ _ [] =
  return ()
takeWhileM_ p (x:xs) =
  do continue <- p x
     when continue $ takeWhileM_ p xs

runUntilFail =  
  takeWhileM_ runKoan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment