-1

Concerning the writing of a function in Haskell, using Gtk (via the package Gtk2Hs); here are my requirements:

  • The function should have the signature:

    affiche :: ((Double,Double), (Double,Double)) -> IO Bool
    
  • The parameters are noted (a0, a), (b0, b); the function should use an external function called mandelbrot: if mandelbrot (a, b) is true, then there must be a call to: postGUIAsync affiche2 a0 b0, where affiche2 is (I also introduced my try to write 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
    

My attempt to write affiche does not use postGUIAsync, and it raises the error:

Error: Couldn't match type ‘Render’ with ‘IO’
  Expected type: IO Bool
    Actual type: Render ()
Mogsdad
  • 44,709
  • 21
  • 151
  • 275
lolveley
  • 1,659
  • 2
  • 18
  • 34

1 Answers1

2

Since you use affiche2 in when, its return type should be IO (), because that's what when accepts. To make it work you need to found out how to turn Render into IO, supposedly with renderWithDrawable.

arrowd
  • 33,231
  • 8
  • 79
  • 110
  • hello,thanks, I no more have compilation errors, but nothing is displayed in the window. please have a look at my new question (I am writing it at the moment) – lolveley Apr 04 '16 at 12:02