Friday, 30 August 2013

What is a neat way to load and store a list of images by name in Haskell?

What is a neat way to load and store a list of images by name in Haskell?

I want to load a list (or any data structure) of images using a bunch of
hardcoded names and an existing function loadImage :: String -> IO Image.
In Lua, I would do the following:
imageNames = {"background", "gun", "man"}
images = {}
for i,v in ipairs(imageNames) do
images[v] = loadImage(v..".png")
end
And access them with images.background, images.man etc. How could I go
about this in Haskell?

No comments:

Post a Comment