如何使用任意字符串(IO())



我正在使用Haskell中的Juicy Pixels库,我想用图像PixelRGB8列表制作GIF动画。. 有一个函数这样做(writeGifAnimation),但它返回的类型,我不知道如何使用(要么字符串(IO()))。有人能帮帮我吗?

我使用它的方式:writeGifAnimation "test.gif" 1 LoopingForever image_list

错误:Couldn't match expected type ‘IO ()’ with actual type ‘Either String (IO ())’

库文档:https://hackage.haskell.org/package/JuicyPixels-3.3.7/docs/Codec-Picture.html v: savePngImage: ~:文本= % 20相同的% 20 delay., writeGifAnimation, % 3 a % % 20 filepath % 20% 2 3 d % 3 e

您应该检查是Left ss错误,还是Right iiIO ()动作,因此:

main :: IO ()
main = do
-- …
casewriteGifAnimation "test.gif" 1 LoopingForever image_listof
Left s -> fail s
Right i -> i
-- …

最新更新