Created
July 28, 2012 22:33
-
-
Save thanthese/3195027 to your computer and use it in GitHub Desktop.
convert [IO String] to IO [String]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- I'm attempting to create a function that converts [IO String] to IO | |
-- [String]. I wasn't able to find one in the standard libraries, but then I'm | |
-- a noob. | |
convert :: [IO String] -> IO [String] | |
convert badWords = convert' badWords [] | |
where | |
convert' [] good = return good | |
convert' bad good = bad >>= (\w -> convert' (tail bad) (w : good)) | |
-- This attempt throws this error. Ideas? | |
-- | |
-- Couldn't match expected type `IO [String]' | |
-- against inferred type `[[IO String]]' | |
-- In the expression: convert' badWords [] | |
-- In the definition of `convert': | |
-- convert badWords | |
-- = convert' badWords [] | |
-- where | |
-- convert' [] good = return good | |
-- convert' bad good = bad >>= (\ w -> convert' (tail bad) (w : good)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment