Skip to content

Instantly share code, notes, and snippets.

@naohaq
Created November 16, 2012 15:18
Show Gist options
  • Save naohaq/4088125 to your computer and use it in GitHub Desktop.
Save naohaq/4088125 to your computer and use it in GitHub Desktop.
Re-implementation of 'sequence'
mysequence :: (Monad m) => [m a] -> m [a]
mysequence xs = loop xs []
where loop [] ys = return $ reverse ys
loop (x:xs) ys = x >>= \y -> loop xs (y:ys)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment