The key here is "The type variable ‘a0’ is ambiguous".

You need to add a type signature to age so the compiler know if age is of type In,Float or Double ...

:)

2014-09-26 10:34 GMT-04:00 Miro Karpis <miroslav.karpis@gmail.com>:
Hi, I'm trying to run an example from the eason documentation:

λ> do result <- decode "{\"name\":\"Dave\",\"age\":2}"
       flip parseMaybe result $ \obj -> do
         age <- obj .: "age"
         name <- obj .: "name"
         return (name ++ ": " ++ show (age*2))


I made a function:

jsonTest = do
result <- decode "{\"name\":\"Dave\",\"age\":2}"
flip parseMaybe result $ \obj -> do
age <- obj .: "age"
name <- obj .: "name"
return (name ++ ": " ++ show (age*2))

which can not compile:
hh.hs:35:41:
No instance for (Show a0) arising from a use of ‘show’
The type variable ‘a0’ is ambiguous
....
...


Please what am I doing wrong?

Cheers, Miro
 


_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners




--
Viva Cila