Skip to content

Instantly share code, notes, and snippets.

@kseo
Created February 12, 2016 04:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kseo/a61c058042ab53ac56c1 to your computer and use it in GitHub Desktop.
Save kseo/a61c058042ab53ac56c1 to your computer and use it in GitHub Desktop.
Monad comprehension
-- https://ghc.haskell.org/trac/ghc/wiki/MonadComprehensions
{-# LANGUAGE MonadComprehensions #-}
import Control.Monad
mapl :: Monad m => (a -> m b) -> ([a] -> m [b])
mapl f [] = return []
mapl f (x:xs) = [y:ys | y <- f x, ys <- mapl f xs]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment