@@ -80,7 +80,7 @@ text =
8080 Right txt
8181
8282 _ ->
83− Left (mkError (Failure value "a string"))
83+ Left (mkError (Failure value "Expecting a STRING"))
8484
8585
8686bool :: Decoder Bool
@@ -91,7 +91,7 @@ bool =
9191 Right boolean
9292
9393 _ ->
94− Left (mkError (Failure value "a boolean"))
94+ Left (mkError (Failure value "Expecting a BOOL"))
9595
9696
9797int :: Decoder Int
@@ -101,13 +101,13 @@ int =
101101 Aeson.Number number ->
102102 case Scientific.toBoundedInteger number of
103103 Nothing ->
104− Left (mkError (Failure value "an integer"))
104+ Left (mkError (Failure value "Expecting an INT"))
105105
106106 Just integer ->
107107 Right integer
108108
109109 _ ->
110− Left (mkError (Failure value "an integer"))
110+ Left (mkError (Failure value "Expecting an INT"))
111111
112112
113113float :: Decoder Float
@@ -118,7 +118,7 @@ float =
118118 Right (Scientific.toRealFloat number)
119119
120120 _ ->
121− Left (mkError (Failure value "a float"))
121+ Left (mkError (Failure value "Expecting a FLOAT"))
122122
123123
124124
@@ -134,7 +134,7 @@ list (Decoder run) =
134134 Vector.imapM (\i v -> run (mkError . Index i) v) vector
135135
136136 _ ->
137− Left (mkError (Failure value "an array"))
137+ Left (mkError (Failure value "Expecting an ARRAY"))
138138
139139
140140dict :: Decoder a -> Decoder (HashMap.HashMap Text a)
@@ -145,7 +145,7 @@ dict (Decoder run) =
145145 HashMap.traverseWithKey (\k v -> run (mkError . Field k) v) hashMap
146146
147147 _ ->
148− Left (mkError (Failure value "an object"))
148+ Left (mkError (Failure value "Expecting an OBJECT"))
149149
150150
151151maybe :: Decoder a -> Decoder (Maybe a)
@@ -173,11 +173,11 @@ field name (Decoder run) =
173173 run (mkError . Field name) v
174174
175175 Nothing ->
176− Left $ mkError $
177− Failure value ("a \"" ++ Text.unpack name ++ "\" field")
176+ Left $ mkError $ Failure value $
177+ "Expecting a \"" ++ Text.unpack name ++ "\" field."
178178
179179 _ ->
180− Left (mkError (Failure value "an object"))
180+ Left (mkError (Failure value "Expecting an OBJECT"))
181181
182182
183183at :: [Text] -> Decoder a -> Decoder a
@@ -199,11 +199,13 @@ index i (Decoder run) =
199199 run (mkError . Index i) v
200200
201201 Nothing ->
202− Left $ mkError $
203− Failure value ("index " ++ show i ++ " of an array")
202+ Left $ mkError $ Failure value $
203+ "Expecting a longer ARRAY. I need index " ++ show i
204+ ++ ", but the array only has " ++ show (Vector.length vector)
205+ ++ " elements."
204206
205207 _ ->
206− Left (mkError (Failure value "an array"))
208+ Left (mkError (Failure value "Expecting an ARRAY"))
207209
208210
209211