[Haskell-cafe] Type errors, would extensions help?
Mauricio
briqueabraque at yahoo.com
Thu Jan 15 07:50:15 EST 2009
Hi,
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:
---
import Data.Ratio ;
main = do {
printNumber <- let {
print :: (Num n,Show n) => n -> IO () ;
print n = do { putStrLn $ show n}
} in return print ;
print (1%5) ;
print 5.0
}
---
However, just removing 'Num n' gives:
Ambiguous type variable `n' in the constraint:
`Show n' arising from a use of `print' at teste.hs:7:16-20
Why is it ambiguous? Since I don't use numeric
functions, 'Num n,Show n' doesn't seem more specific.
Besides that, the real problem I have is a similar
function declared inside a 'let' as
col :: (WidgetClass w) => w->IO Int
col wid = do {...
that, after beeing used with w beeing Table (and
instance WidgetClass Table do exist) refuses beeing
used with DrawingArea (also with instance WidgetClass
DrawingArea), but I wasn't able to simulate that
in a small program, and don't know if it's related
to the case I'm showing.
Thanks for your kindness,
Maurício
More information about the Haskell-Cafe
mailing list