Skip to content

Instantly share code, notes, and snippets.

@JustinSDK
Created February 26, 2015 09:40
Show Gist options
  • Save JustinSDK/3b82f8c605fb1c5c8389 to your computer and use it in GitHub Desktop.
Save JustinSDK/3b82f8c605fb1c5c8389 to your computer and use it in GitHub Desktop.
〈Haskell Tutorial(31)do 區塊與 <- 綁定〉的習題解答
sequence' :: Monad m => [m a] -> m [a]
sequence' [] = return []
sequence' (x:xs) = do
value <- x
values <- sequence' xs
return (value : values)
forM' :: Monad m => [a] -> (a -> m b) -> m [b]
forM' xs f = sequence' $ map f xs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment