Search code examples
haskellmonad-transformersio-monad

Haskell: monad stack bind with IO and []


I have:

stuff :: IO [String]
doThings :: String -> IO [()]

and I want to

stuff >>= doThings

but my types are off. I want to do a lifted bind essentially but everything I try is subtly wrong.


Solution

  • With your original types, you can do:

    stuff >>= mapM_ doThings
    

    This also works if you change doThings to have type doThings :: String -> IO ()