снепшоте.
Есть вот такой кусочек:
readHFile :: FilePath -> IO (FilePath,HoHeader, forall a . Data.Binary.Binary a => ChunkType -> a)
readHFile fn = do
bs <- BS.readFile fn
fn' <- shortenPath fn
(ct,mp) <- bsCFF bs
True <- return $ ct == cff_magic
let fc :: forall a . Data.Binary.Binary a => ChunkType -> a
fc ct = case lookup ct mp of
Nothing -> error $ "No chunk '" ++ show ct ++ "' found in file " ++ fn
Just x -> decode $ decompress $ LBS.fromStrict x
let hoh = fc cff_jhdr
when (hohVersion hoh /= ho_version) $ fail "invalid version in hofile"
return (fn',hoh,fc)
Вот это чудо не компиляется с ошибкой
hc-core> • Couldn't match type ‘ChunkType -> a0’
jhc-core> with ‘forall a. Binary a => ChunkType -> a’
jhc-core> Expected type: IO
jhc-core> (FilePath, HoHeader, forall a. Binary a => ChunkType -> a)
jhc-core> Actual type: IO (String, HoHeader, ChunkType -> a0)
jhc-core> • In a stmt of a 'do' block: return (fn', hoh, fc)
jhc-core> In the expression:
jhc-core> do bs <- BS.readFile fn
jhc-core> fn' <- shortenPath fn
jhc-core> (ct, mp) <- bsCFF bs
jhc-core> True <- return $ ct == cff_magic
jhc-core> ....
jhc-core> In an equation for ‘readHFile’:
jhc-core> readHFile fn
jhc-core> = do bs <- BS.readFile fn
jhc-core> fn' <- shortenPath fn
jhc-core> (ct, mp) <- bsCFF bs
jhc-core> ....
jhc-core> |
jhc-core> 35 | return (fn',hoh,fc)
Не могу понять, как же так. Есть идеи? Вроде как у fc правильный тип, полиморфная функция.
заверни в нютайп
Обсуждают сегодня