I am very new to Haskell and do not have good understanding of monads for now. I am using gloss for making chess. The issue I am facing is in the loading of multiple images. I am using loadBMP
function provided by haskell to load image. Its signature is:
loadBMP :: FilePath -> IO Picture
I can load single image but can't load array of images.
-- This function calculates the path of all the images and then apply loadBMP function on it.
loadPieceImages :: [IO Picture]
loadPieceImages = do
map (loadBMP . (\n -> "images/" ++ n ++ ".bmp") . (\n -> if n < 6 then show n ++ "-w" else show (n `mod` 6) ++ "-b")) [0 .. 12]
main :: IO ()
main = do
images <- loadPieceImages -- On this line I am getting error.
play window (makeColor 1 0 0 1) 30 initialState draw transform (const id)
The main issue is that I have [IO Picture]
type but I don't how will be turn it into [Picture]
.
This thing might be very basic but I can't understand monads for now. So kindly explain the answer you give.