I'm working through Artyom's Aeson tutorial, and have coded myself this snippet:
parseFoo (Object obj) = do
a <- case HM.lookup "a" obj of
Just x -> parseJSON x
Nothing -> fail "no field 'a'"
return a
I've noticed that if I return True
, I get an "ambiguous reference" error:
No instance for (FromJSON t0) arising from a use of ‘parseJSON’
The type variable ‘t0’ is ambiguous
Note: there are several potential instances:
...
The type of the non-ambiguous case is
parseFoo :: FromJSON b => Value -> Parser b
My question is, why (how) does a
need the return
statement to infer its type?