[Haskell-beginners] aeson json paring

Miro Karpis miroslav.karpis at gmail.com
Fri Sep 26 14:34:32 UTC 2014


Hi, I'm trying to run an example from the eason documentation
<https://hackage.haskell.org/package/aeson-0.6.1.0/docs/Data-Aeson.html#g:3>
:

λ> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20140926/f1394940/attachment.html>


More information about the Beginners mailing list