@@ -59,6 +59,7 @@ import Data.Number.Scientific (Scientific)
5959import Data.Primitive (SmallArray )
6060import Data.Primitive.Unlifted.Array (UnliftedArray )
6161import Data.Profunctor (Profunctor (.. ))
62+ import Data.Text (Text )
6263import Data.Text.Short (ShortText )
6364import Data.Word (Word16 , Word64 )
6465import Json (Member (Member ), Value (Array , Number , Object , String ))
@@ -94,7 +95,7 @@ array = P $ \ctx v -> case v of
9495 Array membs -> Right (ctx, Elements membs)
9596 _ -> Left (Errors. singleton (Error " expected array" ctx))
9697
97- string :: Value ~> ShortText
98+ string :: Value ~> Text
9899string = P $ \ ctx v -> case v of
99100 String str -> Right (ctx, str)
100101 _ -> Left (Errors. singleton (Error " expected string" ctx))
@@ -106,7 +107,7 @@ string = P $ \ctx v -> case v of
106107Failure context includes the index of non-string value if any values in
107108the array are not strings.
108109-}
109- strings :: Value ~> UnliftedArray ShortText
110+ strings :: Value ~> SmallArray Text
110111strings = P $ \ ctx v -> case v of
111112 Array membs -> runST $ runExceptT $ do
112113 xs <-
@@ -137,15 +138,15 @@ null = P $ \ctx v -> case v of
137138
138139newtype Members = Members { unMembers :: SmallArray Member }
139140
140- member :: ShortText -> Members ~> Value
141+ member :: Text -> Members ~> Value
141142member k = P $ \ ctx xs -> case find keyEq (unMembers xs) of
142143 Just Member {value} -> Right (Key k ctx, value)
143144 Nothing -> Left (Errors. singleton (Error (" key not found: " <> k) ctx))
144145 where
145146 keyEq Member {key} = k == key
146147
147148-- | An optional member. Returns Nothing if the value is missing.
148- memberOpt :: ShortText -> Members ~> Maybe Value
149+ memberOpt :: Text -> Members ~> Maybe Value
149150memberOpt k = P $ \ ctx xs -> case find keyEq (unMembers xs) of
150151 Just Member {value} -> Right (Key k ctx, Just value)
151152 Nothing -> Right (ctx, Nothing )
@@ -248,15 +249,15 @@ instance ArrowChoice Parser where
248249instance ArrowApply Parser where
249250 app = P $ \ ctx (p, x) -> unParser p ctx x
250251
251- fail :: ShortText -> a ~> b
252+ fail :: Text -> a ~> b
252253fail msg = P $ \ ctx _ -> Left (Errors. singleton (Error msg ctx))
253254
254255failZero :: a ~> b
255256failZero = P $ \ ctx _ -> Left (Errors. singleton (Error " " ctx))
256257
257258liftMaybe ::
258259 -- | Message to display on decode error
259- ShortText ->
260+ Text ->
260261 -- | Decode function
261262 (a -> Maybe b ) ->
262263 a ~> b
0 commit comments