@@ -80,7 +80,7 @@ text =
83− Left (mkError (Failure value "a string"))
83+ Left (mkError (Failure value "Expecting a STRING"))
86bool :: Decoder Bool
86bool :: Decoder Bool
@@ -91,7 +91,7 @@ bool =
91 Right boolean
91 Right boolean
94− Left (mkError (Failure value "a boolean"))
94+ Left (mkError (Failure value "Expecting a BOOL"))
97int :: Decoder Int
97int :: Decoder Int
@@ -101,13 +101,13 @@ int =
101 Aeson.Number number ->
101 Aeson.Number number ->
102 case Scientific.toBoundedInteger number of
102 case Scientific.toBoundedInteger number of
103 Nothing ->
103 Nothing ->
104− Left (mkError (Failure value "an integer"))
104+ Left (mkError (Failure value "Expecting an INT"))
106 Just integer ->
106 Just integer ->
107 Right integer
107 Right integer
110− Left (mkError (Failure value "an integer"))
110+ Left (mkError (Failure value "Expecting an INT"))
113float :: Decoder Float
113float :: Decoder Float
@@ -118,7 +118,7 @@ float =
118 Right (Scientific.toRealFloat number)
118 Right (Scientific.toRealFloat number)
121− Left (mkError (Failure value "a float"))
121+ Left (mkError (Failure value "Expecting a FLOAT"))
@@ -134,7 +134,7 @@ list (Decoder run) =
134 Vector.imapM (\i v -> run (mkError . Index i) v) vector
134 Vector.imapM (\i v -> run (mkError . Index i) v) vector
137− Left (mkError (Failure value "an array"))
137+ Left (mkError (Failure value "Expecting an ARRAY"))
140dict :: Decoder a -> Decoder (HashMap.HashMap Text a)
140dict :: Decoder a -> Decoder (HashMap.HashMap Text a)
@@ -145,7 +145,7 @@ dict (Decoder run) =
145 HashMap.traverseWithKey (\k v -> run (mkError . Field k) v) hashMap
145 HashMap.traverseWithKey (\k v -> run (mkError . Field k) v) hashMap
148− Left (mkError (Failure value "an object"))
148+ Left (mkError (Failure value "Expecting an OBJECT"))
151maybe :: Decoder a -> Decoder (Maybe a)
151maybe :: Decoder a -> Decoder (Maybe a)
@@ -173,11 +173,11 @@ field name (Decoder run) =
173 run (mkError . Field name) v
173 run (mkError . Field name) v
175 Nothing ->
175 Nothing ->
176− Left $ mkError $
176+ Left $ mkError $ Failure value $
177− Failure value ("a \"" ++ Text.unpack name ++ "\" field")
177+ "Expecting a \"" ++ Text.unpack name ++ "\" field."
180− Left (mkError (Failure value "an object"))
180+ Left (mkError (Failure value "Expecting an OBJECT"))
183at :: [Text] -> Decoder a -> Decoder a
183at :: [Text] -> Decoder a -> Decoder a
@@ -199,11 +199,13 @@ index i (Decoder run) =
199 run (mkError . Index i) v
199 run (mkError . Index i) v
201 Nothing ->
201 Nothing ->
202− Left $ mkError $
202+ Left $ mkError $ Failure value $
203− Failure value ("index " ++ show i ++ " of an array")
203+ "Expecting a longer ARRAY. I need index " ++ show i
204+ ++ ", but the array only has " ++ show (Vector.length vector)
206− Left (mkError (Failure value "an array"))
208+ Left (mkError (Failure value "Expecting an ARRAY"))