2016-04-03 49 views
-2

关于在Haskell中编写函数,使用Gtk(通过包Gtk2Hs);这里是我的要求:使用效率错误

  • 的功能应该有签名:

    affiche :: ((Double,Double), (Double,Double)) -> IO Bool 
    
  • 的参数说明(A0,A),(B0,B);该函数应该使用一个名为mandelbrot的外部函数:如果mandelbrot(a,b)为true,那么必须有一个调用:postGUIAsync affiche2 a0 b0,其中affiche2是(我也介绍了我的尝试编写affiche):

    affiche2 :: Double -> Double -> Render() 
    affiche2 a b = do 
        C.rectangle a b 1 1 
        stroke 
    
    affiche :: ((Double,Double), (Double,Double)) -> IO Bool 
    affiche ((a0,a), (b0,b)) = when (mandelbrot a b) $ affiche2 a0 b0 
    

我尝试写网站公告不使用postGUIAsync,并引发错误:

Error: Couldn't match type ‘Render’ with ‘IO’ 
    Expected type: IO Bool 
    Actual type: Render() 

回答

2

既然你在when使用affiche2,它的返回类型应该是IO(),因为这是when接受秒。为了使它工作,你需要找出如何将Render变成IO,据推测与renderWithDrawable

+0

你好,谢谢,我没有更多的编译错误,但没有任何显示在窗口中。请看看我的新问题(我现在正在写) – lolveley