on master help sign in
Rename liftParseField* to explicitParseField*
a122b2eOleg Grenrus
Data/Aeson/Types.hs+3−3
@@ -93,9 +93,9 @@ module Data.Aeson.Types
93 , parseField
93 , parseField
94 , parseFieldMaybe
94 , parseFieldMaybe
95 , parseFieldMaybe'
95 , parseFieldMaybe'
96− , liftParseField
96+ , explicitParseField
97− , liftParseFieldMaybe
97+ , explicitParseFieldMaybe
98− , liftParseFieldMaybe'
98+ , explicitParseFieldMaybe'
99
99
100 , listEncoding
100 , listEncoding
101 , listValue
101 , listValue
Data/Aeson/Types/Class.hs+3−3
@@ -80,9 +80,9 @@ module Data.Aeson.Types.Class
80 , parseField
80 , parseField
81 , parseFieldMaybe
81 , parseFieldMaybe
82 , parseFieldMaybe'
82 , parseFieldMaybe'
83− , liftParseField
83+ , explicitParseField
84− , liftParseFieldMaybe
84+ , explicitParseFieldMaybe
85− , liftParseFieldMaybe'
85+ , explicitParseFieldMaybe'
86 -- ** Operators
86 -- ** Operators
87 , (.:)
87 , (.:)
88 , (.:?)
88 , (.:?)
Data/Aeson/Types/FromJSON.hs+16−16
@@ -63,9 +63,9 @@ module Data.Aeson.Types.FromJSON
63 , parseField
63 , parseField
64 , parseFieldMaybe
64 , parseFieldMaybe
65 , parseFieldMaybe'
65 , parseFieldMaybe'
66− , liftParseField
66+ , explicitParseField
67− , liftParseFieldMaybe
67+ , explicitParseFieldMaybe
68− , liftParseFieldMaybe'
68+ , explicitParseFieldMaybe'
69 -- ** Operators
69 -- ** Operators
70 , (.:)
70 , (.:)
71 , (.:?)
71 , (.:?)
@@ -661,7 +661,7 @@ ifromJSON = iparse parseJSON
661-- in an object for it to be valid. If the key and value are
661-- in an object for it to be valid. If the key and value are
662-- optional, use '.:?' instead.
662-- optional, use '.:?' instead.
663(.:) :: (FromJSON a) => Object -> Text -> Parser a
663(.:) :: (FromJSON a) => Object -> Text -> Parser a
664−(.:) = liftParseField parseJSON
664+(.:) = explicitParseField parseJSON
665{-# INLINE (.:) #-}
665{-# INLINE (.:) #-}
666
666
667-- | Retrieve the value associated with the given key of an 'Object'. The
667-- | Retrieve the value associated with the given key of an 'Object'. The
@@ -672,7 +672,7 @@ ifromJSON = iparse parseJSON
672-- from an object without affecting its validity. If the key and
672-- from an object without affecting its validity. If the key and
673-- value are mandatory, use '.:' instead.
673-- value are mandatory, use '.:' instead.
674(.:?) :: (FromJSON a) => Object -> Text -> Parser (Maybe a)
674(.:?) :: (FromJSON a) => Object -> Text -> Parser (Maybe a)
675−(.:?) = liftParseFieldMaybe parseJSON
675+(.:?) = explicitParseFieldMaybe parseJSON
676{-# INLINE (.:?) #-}
676{-# INLINE (.:?) #-}
677
677
678-- | Retrieve the value associated with the given key of an 'Object'.
678-- | Retrieve the value associated with the given key of an 'Object'.
@@ -682,7 +682,7 @@ ifromJSON = iparse parseJSON
682-- This differs from '.:?' by attempting to parse 'Null' the same as any
682-- This differs from '.:?' by attempting to parse 'Null' the same as any
683-- other JSON value, instead of interpreting it as 'Nothing'.
683-- other JSON value, instead of interpreting it as 'Nothing'.
684(.:!) :: (FromJSON a) => Object -> Text -> Parser (Maybe a)
684(.:!) :: (FromJSON a) => Object -> Text -> Parser (Maybe a)
685−(.:!) = liftParseFieldMaybe' parseJSON
685+(.:!) = explicitParseFieldMaybe' parseJSON
686{-# INLINE (.:!) #-}
686{-# INLINE (.:!) #-}
687
687
688-- | Function variant of '.:'.
688-- | Function variant of '.:'.
@@ -702,26 +702,26 @@ parseFieldMaybe' = (.:!)
702
702
703-- | Variant of '.:' with explicit parser function.
703-- | Variant of '.:' with explicit parser function.
704--
704--
705−-- E.g. @'liftParseField' 'parseJSON1' :: ('FromJSON1' f, 'FromJSON' a) -> 'Object' -> 'Text' -> 'Parser' (f a)@
705+-- E.g. @'explicitParseField' 'parseJSON1' :: ('FromJSON1' f, 'FromJSON' a) -> 'Object' -> 'Text' -> 'Parser' (f a)@
706−liftParseField :: (Value -> Parser a) -> Object -> Text -> Parser a
706+explicitParseField :: (Value -> Parser a) -> Object -> Text -> Parser a
707−liftParseField p obj key = case H.lookup key obj of
707+explicitParseField p obj key = case H.lookup key obj of
708 Nothing -> fail $ "key " ++ show key ++ " not present"
708 Nothing -> fail $ "key " ++ show key ++ " not present"
709 Just v -> p v <?> Key key
709 Just v -> p v <?> Key key
710−{-# INLINE liftParseField #-}
710+{-# INLINE explicitParseField #-}
711
711
712-- | Variant of '.:?' with explicit parser function.
712-- | Variant of '.:?' with explicit parser function.
713−liftParseFieldMaybe :: (Value -> Parser a) -> Object -> Text -> Parser (Maybe a)
713+explicitParseFieldMaybe :: (Value -> Parser a) -> Object -> Text -> Parser (Maybe a)
714−liftParseFieldMaybe p obj key = case H.lookup key obj of
714+explicitParseFieldMaybe p obj key = case H.lookup key obj of
715 Nothing -> pure Nothing
715 Nothing -> pure Nothing
716 Just v -> liftParseJSON p (listParser p) v <?> Key key -- listParser isn't used by maybe instance.
716 Just v -> liftParseJSON p (listParser p) v <?> Key key -- listParser isn't used by maybe instance.
717−{-# INLINE liftParseFieldMaybe #-}
717+{-# INLINE explicitParseFieldMaybe #-}
718
718
719-- | Variant of '.:!' with explicit parser function.
719-- | Variant of '.:!' with explicit parser function.
720−liftParseFieldMaybe' :: (Value -> Parser a) -> Object -> Text -> Parser (Maybe a)
720+explicitParseFieldMaybe' :: (Value -> Parser a) -> Object -> Text -> Parser (Maybe a)
721−liftParseFieldMaybe' p obj key = case H.lookup key obj of
721+explicitParseFieldMaybe' p obj key = case H.lookup key obj of
722 Nothing -> pure Nothing
722 Nothing -> pure Nothing
723 Just v -> Just <$> p v <?> Key key
723 Just v -> Just <$> p v <?> Key key
724−{-# INLINE liftParseFieldMaybe' #-}
724+{-# INLINE explicitParseFieldMaybe' #-}
725
725
726-- | Helper for use in combination with '.:?' to provide default
726-- | Helper for use in combination with '.:?' to provide default
727-- values for optional JSON object fields.
727-- values for optional JSON object fields.