module FourCC where import Data.Bits import Data.Int fromString :: String -> Int32 fromString full_string = let code_string = take 4 full_string ~[c4,c3,c2,c1] = code_string byte4 :: Int32 = shiftL (fromIntegral $ fromEnum c4) 24 byte3 :: Int32 = shiftL (fromIntegral $ fromEnum c3) 16 byte2 :: Int32 = shiftL (fromIntegral $ fromEnum c2) 8 byte1 :: Int32 = fromIntegral $ fromEnum c1 in byte4 .|. byte3 .|. byte2 .|. byte1