Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 14th, 2012  |  syntax: None  |  size: 0.90 KB  |  hits: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Ambiguous type variable `a0' in the constraints
  2. module Main where
  3.  
  4. main :: IO ()
  5.  
  6. main = putStrLn ( show (yesno 12) )
  7.  
  8. class YesNo a where
  9.     yesno :: a -> Bool
  10.  
  11.  
  12. instance YesNo Bool where
  13.     yesno b = b
  14.  
  15. instance YesNo [a] where
  16.     yesno [] = False
  17.     yesno _ = True
  18.  
  19.  
  20. instance YesNo Int where
  21.     yesno 0 = False
  22.     yesno _ = True
  23.        
  24. Ambiguous type variable `a0' in the constraints:
  25.   (YesNo a0) arising from a use of `yesno'
  26.              at /Users/mkhadikov/Projects/personal/haskell/hello-world/yesno.hs:5:25-29
  27.   (Num a0) arising from the literal `12'
  28.            at /Users/mkhadikov/Projects/personal/haskell/hello-world/yesno.hs:5:31-32
  29. Probable fix: add a type signature that fixes these type variable(s)
  30. In the first argument of `show', namely `(yesno 12)'
  31. In the first argument of `putStrLn', namely `(show (yesno 12))'
  32. In the expression: putStrLn (show (yesno 12))
  33.        
  34. GHCi> :t 12
  35. 12 :: Num a => a