
13 Sep
2015
13 Sep
'15
1:15 a.m.
Hi list,
ghci> decode $ fromStrict $ encodeUtf8 $ "{\"a\" : \"b\"}" Nothing
ghci> decode $ fromStrict $ encodeUtf8 $ "{\"a\" : \"b\"}" :: Maybe Object Just (fromList [("a",String "b")])
The question is: how can the first example compile? I would expect that since GHC cannot infer the type I want from Aeson to decode to, it would die with an error that "t0 type variable is ambigious". But instead, it compiles just fine, and fails runtime. How it's decided what type should Aeson try to decode to? What type is that gives me Nothing on whatever JSON input I give? Cheers, Andras Sevcsik -- Minden jót, Sevcsik András