when I want to load a bmp file I do this with:
loadBMP :: String -> IO Picture
If it isn't certain if the given path exists one could do something as follows:
saveLoad :: String -> IO Picture
saveLoad str = do
b <- doesFileExist str
if b then loadBMP str
else return Blank
Another way could also be; to use monad transformer:
saveLoadM :: String -> MaybeT IO Picture
saveLoadM s = do
b <- lift $ doesFileExist s
if b then do
p <- lift$ loadBMP s
return p
else MaybeT $ return Nothing
But how would you deal with a list of files?
test ::[String] -> ListT IO Picture
test [] = ListT $ return []
test (x:xs) = do
b <- lift $ doesFileExist x
if b then do
p <- lift$ loadBMP x
return p -- would yield a simple [p]
-- therefore:
p : test xs -- wrong -> not working
else test xs