
I have this problem trying to define a function inside a do expression. I tried this small code to help me check. This works well:
I guess you intended to call printNumber in the quoted snippet? (...) {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ImpredicativeTypes #-}
After you pointed my dumb mistake, I was able to build the first example -- without any of the extensions! Haskell can be misterious some times. Strange enough, I can't get the original (and, to my eyes, equal) problem to work. This is the smallest I could get it to be: --- WARNING: wrong use of gtk, just to get an example --- import Graphics.UI.Gtk ; main = do { initGUI ; j1 <- drawingAreaNew ; j2 <- tableNew 1 1 True ; notebook <- do { note <- notebookNew ; insertInNotebook <- let { colocar :: (WidgetClass w) => w -> String -> IO Int ; colocar wid texto = do { lb <- labelNew Nothing ; labelSetMarkup lb texto ; notebookAppendPageMenu note wid lb lb } } in return $ colocar ; insertInNotebook j1 "J1" ; insertInNotebook j2 "J2" ; return note } ; putStrLn "Finish" } --- GHC says: teste.hs:15:21: Couldn't match expected type `DrawingArea' against inferred type `Table' In the first argument of `insertInNotebook', namely `j2' In a stmt of a 'do' expression: insertInNotebook j2 "J2" (...) but I would like first argument of insert... to be any instance of WidgetClass, be it Drawing... or Table. Thanks, MaurĂcio