Reputation: 1182
In Haskell, how would one go about writing to an arbitrarily large number of files?
As an example, let's say I want to take the letters a
through z
and put them in files named for the letter of their contents. An initial attempt was to do the following:
main :: IO ()
main = do
let letter = map (:"") ['a'..'z']
zipWith writeFile letter letter
which produced the following error:
Couldn't match expected type 'IO ()' with actual type '[IO ()]'
I feel like there should be a way to loop through a list in a do block, but I haven't been able to find it yet.
Upvotes: 1
Views: 398