Commits

basvandijk committed d88380d

Rename constructor name/type to constructor tag which is more accurate.

- Rename "constructorNameModifier" to "constructorTagModifier".

- Rename "ObjectWithType" to "TaggedObject".

- Rename "typeFieldName" to "tagFieldName".

- Rename "defaultObjectWithType" to "defaultTaggedObject".

Comments (0)

Files changed (4)

 lower-casing them:
 
 @
-$('deriveJSON' 'defaultOptions'{'fieldNameModifier' = 'drop' 4, 'constructorNameModifier' = map toLower} ''D)
+$('deriveJSON' 'defaultOptions'{'fieldNameModifier' = 'drop' 4, 'constructorTagModifier' = map toLower} ''D)
 @
 
 Now we can use the newly created instances.
 
 module Data.Aeson.TH
     ( -- * Encoding configuration
-      Options(..), SumEncoding(..), defaultOptions, defaultObjectWithType
+      Options(..), SumEncoding(..), defaultOptions, defaultTaggedObject
 
      -- * FromJSON and ToJSON derivation
     , deriveJSON
                         , Options(..)
                         , SumEncoding(..)
                         , defaultOptions
-                        , defaultObjectWithType
+                        , defaultTaggedObject
                         )
 -- from base:
 import Control.Applicative ( pure, (<$>), (<*>) )
 conTxt opts = appE [|T.pack|] . conStringE opts
 
 conStringE :: Options -> Name -> Q Exp
-conStringE opts = stringE . constructorNameModifier opts . nameBase
+conStringE opts = stringE . constructorTagModifier opts . nameBase
 
 -- | If constructor is nullary.
 isNullary :: Con -> Bool
         case sumEncoding opts of
           TwoElemArray ->
               [|Array|] `appE` ([|V.fromList|] `appE` listE [conStr opts conName, exp])
-          ObjectWithType{typeFieldName, contentsFieldName} ->
+          TaggedObject{tagFieldName, contentsFieldName} ->
               [|object|] `appE` listE
-                [ infixApp [|T.pack typeFieldName|]     [|(.=)|] (conStr opts conName)
+                [ infixApp [|T.pack tagFieldName|]     [|(.=)|] (conStr opts conName)
                 , infixApp [|T.pack contentsFieldName|] [|(.=)|] exp
                 ]
           ObjectWithSingleField ->
           $ if multiCons
             then case sumEncoding opts of
                    TwoElemArray -> [|toJSON|] `appE` tupE [conStr opts conName, exp]
-                   ObjectWithType{typeFieldName} ->
+                   TaggedObject{tagFieldName} ->
                        [|object|] `appE`
                          -- TODO: Maybe throw an error in case
-                         -- typeFieldName overwrites a field in pairs.
-                         infixApp (infixApp [|T.pack typeFieldName|]
+                         -- tagFieldName overwrites a field in pairs.
+                         infixApp (infixApp [|T.pack tagFieldName|]
                                             [|(.=)|]
                                             (conStr opts conName))
                                   [|(:)|]
 
     mixedMatches =
         case sumEncoding opts of
-          ObjectWithType {typeFieldName, contentsFieldName} ->
-            parseObject $ parseObjectWithType typeFieldName contentsFieldName
+          TaggedObject {tagFieldName, contentsFieldName} ->
+            parseObject $ parseTaggedObject tagFieldName contentsFieldName
           ObjectWithSingleField ->
             parseObject $ parseObjectWithSingleField
           TwoElemArray ->
                    []
         ]
 
-    parseObjectWithType typFieldName valFieldName obj = do
+    parseTaggedObject typFieldName valFieldName obj = do
       conKey <- newName "conKey"
       doE [ bindS (varP conKey)
                   (infixApp (varE obj)
                             [|(.:)|]
                             ([|T.pack|] `appE` stringE typFieldName))
-          , noBindS $ parseContents conKey (Left (valFieldName, obj)) 'conNotFoundFailObjectWithType
+          , noBindS $ parseContents conKey (Left (valFieldName, obj)) 'conNotFoundFailTaggedObject
           ]
 
     parse2ElemArray arr = do
                                    `appE` (litE $ stringL $ show tName)
                                    `appE` listE (map ( litE
                                                      . stringL
-                                                     . constructorNameModifier opts
+                                                     . constructorTagModifier opts
                                                      . nameBase
                                                      . getConName
                                                      ) cons
     where
       x:xs = [ [|lookupField|]
                `appE` (litE $ stringL $ show tName)
-               `appE` (litE $ stringL $ constructorNameModifier opts $ nameBase conName)
+               `appE` (litE $ stringL $ constructorTagModifier opts $ nameBase conName)
                `appE` (varE obj)
                `appE` ( [|T.pack|] `appE` fieldNameExp opts field
                       )
 
 wrongPairCountFail :: String -> String -> Parser fail
 wrongPairCountFail t n =
-    fail $ printf "When parsing %s expected an Object with a single name/value pair but got %s pairs."
+    fail $ printf "When parsing %s expected an Object with a single tag/contents pair but got %s pairs."
                   t n
 
 noStringFail :: String -> String -> Parser fail
 
 noMatchFail :: String -> String -> Parser fail
 noMatchFail t o =
-    fail $ printf "When parsing %s expected a String with the name of a constructor but got %s." t o
+    fail $ printf "When parsing %s expected a String with the tag of a constructor but got %s." t o
 
 not2ElemArray :: String -> Int -> Parser fail
 not2ElemArray t i = fail $ printf "When parsing %s expected an Array of 2 elements but got %i elements" t i
 
 conNotFoundFail2ElemArray :: String -> [String] -> String -> Parser fail
 conNotFoundFail2ElemArray t cs o =
-    fail $ printf "When parsing %s expected a 2-element Array with a name and value element where the name is one of [%s], but got %s."
+    fail $ printf "When parsing %s expected a 2-element Array with a tag and contents element where the tag is one of [%s], but got %s."
                   t (intercalate ", " cs) o
 
 conNotFoundFailObjectSingleField :: String -> [String] -> String -> Parser fail
 conNotFoundFailObjectSingleField t cs o =
-    fail $ printf "When parsing %s expected an Object with a name/value pair where the name is one of [%s], but got %s."
+    fail $ printf "When parsing %s expected an Object with a single tag/contents pair where the tag is one of [%s], but got %s."
                   t (intercalate ", " cs) o
 
-conNotFoundFailObjectWithType :: String -> [String] -> String -> Parser fail
-conNotFoundFailObjectWithType t cs o =
-    fail $ printf "When parsing %s expected an Object with a type field where the value is one of [%s], but got %s."
+conNotFoundFailTaggedObject :: String -> [String] -> String -> Parser fail
+conNotFoundFailTaggedObject t cs o =
+    fail $ printf "When parsing %s expected an Object with a tag field where the value is one of [%s], but got %s."
                   t (intercalate ", " cs) o
 
 parseTypeMismatch' :: String -> String -> String -> String -> Parser fail
 conNameExp :: Options -> Con -> Q Exp
 conNameExp opts = litE
                 . stringL
-                . constructorNameModifier opts
+                . constructorTagModifier opts
                 . nameBase
                 . getConName
 

Data/Aeson/Types.hs

     , Options(..)
     , SumEncoding(..)
     , defaultOptions
-    , defaultObjectWithType
+    , defaultTaggedObject
     ) where
 
 import Data.Aeson.Types.Class

Data/Aeson/Types/Generic.hs

     sumToJSON :: Options -> f a -> Tagged allNullary Value
 
 instance ( GetConName            f
-         , ObjectWithType        f
+         , TaggedObject          f
          , ObjectWithSingleField f
          , TwoElemArray          f ) => SumToJSON f True where
     sumToJSON opts
         | nullaryToString opts = Tagged . String . pack
-                               . constructorNameModifier opts . getConName
+                               . constructorTagModifier opts . getConName
         | otherwise = Tagged . nonAllNullarySumToJSON opts
     {-# INLINE sumToJSON #-}
 
 instance ( TwoElemArray          f
-         , ObjectWithType        f
+         , TaggedObject          f
          , ObjectWithSingleField f ) => SumToJSON f False where
     sumToJSON opts = Tagged . nonAllNullarySumToJSON opts
     {-# INLINE sumToJSON #-}
 
 nonAllNullarySumToJSON :: ( TwoElemArray          f
-                          , ObjectWithType        f
+                          , TaggedObject          f
                           , ObjectWithSingleField f
                           ) => Options -> f a -> Value
 nonAllNullarySumToJSON opts =
     case sumEncoding opts of
-      ObjectWithType{..}    -> object . objectWithType opts typeFieldName
-                                                            contentsFieldName
+      TaggedObject{..}      -> object . taggedObject opts tagFieldName
+                                                          contentsFieldName
       ObjectWithSingleField -> Object . objectWithSingleField opts
       TwoElemArray          -> Array  . twoElemArray opts
 {-# INLINE nonAllNullarySumToJSON #-}
 
 --------------------------------------------------------------------------------
 
-class ObjectWithType f where
-    objectWithType :: Options -> String -> String -> f a -> [Pair]
+class TaggedObject f where
+    taggedObject :: Options -> String -> String -> f a -> [Pair]
 
-instance ( ObjectWithType a
-         , ObjectWithType b ) => ObjectWithType (a :+: b) where
-    objectWithType     opts typeFieldName contentsFieldName (L1 x) =
-        objectWithType opts typeFieldName contentsFieldName     x
-    objectWithType     opts typeFieldName contentsFieldName (R1 x) =
-        objectWithType opts typeFieldName contentsFieldName     x
-    {-# INLINE objectWithType #-}
+instance ( TaggedObject a
+         , TaggedObject b ) => TaggedObject (a :+: b) where
+    taggedObject     opts tagFieldName contentsFieldName (L1 x) =
+        taggedObject opts tagFieldName contentsFieldName     x
+    taggedObject     opts tagFieldName contentsFieldName (R1 x) =
+        taggedObject opts tagFieldName contentsFieldName     x
+    {-# INLINE taggedObject #-}
 
-instance ( IsRecord        a isRecord
-         , ObjectWithType' a isRecord
-         , Constructor c ) => ObjectWithType (C1 c a) where
-    objectWithType opts typeFieldName contentsFieldName =
-        (pack typeFieldName .= constructorNameModifier opts
+instance ( IsRecord      a isRecord
+         , TaggedObject' a isRecord
+         , Constructor c ) => TaggedObject (C1 c a) where
+    taggedObject opts tagFieldName contentsFieldName =
+        (pack tagFieldName .= constructorTagModifier opts
                                  (conName (undefined :: t c a p)) :) .
         (unTagged :: Tagged isRecord [Pair] -> [Pair]) .
-          objectWithType' opts contentsFieldName . unM1
-    {-# INLINE objectWithType #-}
+          taggedObject' opts contentsFieldName . unM1
+    {-# INLINE taggedObject #-}
 
-class ObjectWithType' f isRecord where
-    objectWithType' :: Options -> String -> f a -> Tagged isRecord [Pair]
+class TaggedObject' f isRecord where
+    taggedObject' :: Options -> String -> f a -> Tagged isRecord [Pair]
 
-instance (RecordToPairs f) => ObjectWithType' f True where
-    objectWithType' opts _ = Tagged . toList . recordToPairs opts
-    {-# INLINE objectWithType' #-}
+instance (RecordToPairs f) => TaggedObject' f True where
+    taggedObject' opts _ = Tagged . toList . recordToPairs opts
+    {-# INLINE taggedObject' #-}
 
-instance (GToJSON f) => ObjectWithType' f False where
-    objectWithType' opts contentsFieldName =
+instance (GToJSON f) => TaggedObject' f False where
+    taggedObject' opts contentsFieldName =
         Tagged . (:[]) . (pack contentsFieldName .=) . gToJSON opts
-    {-# INLINE objectWithType' #-}
+    {-# INLINE taggedObject' #-}
 
 --------------------------------------------------------------------------------
 
          , Constructor c ) => TwoElemArray (C1 c a) where
     twoElemArray opts x = V.create $ do
       mv <- VM.unsafeNew 2
-      VM.unsafeWrite mv 0 $ String $ pack $ constructorNameModifier opts
+      VM.unsafeWrite mv 0 $ String $ pack $ constructorTagModifier opts
                                    $ conName (undefined :: t c a p)
       VM.unsafeWrite mv 1 $ gToJSON opts x
       return mv
          , Constructor c ) => ObjectWithSingleField (C1 c a) where
     objectWithSingleField opts = H.singleton typ . gToJSON opts
         where
-          typ = pack $ constructorNameModifier opts $
+          typ = pack $ constructorTagModifier opts $
                          conName (undefined :: t c a p)
     {-# INLINE objectWithSingleField #-}
 
 class ParseSum f allNullary where
     parseSum :: Options -> Value -> Tagged allNullary (Parser (f a))
 
-instance ( SumFromString      (a :+: b)
-         , FromPair           (a :+: b)
-         , FromObjectWithType (a :+: b) ) => ParseSum (a :+: b) True where
+instance ( SumFromString    (a :+: b)
+         , FromPair         (a :+: b)
+         , FromTaggedObject (a :+: b) ) => ParseSum (a :+: b) True where
     parseSum opts
         | nullaryToString opts = Tagged . parseAllNullarySum    opts
         | otherwise            = Tagged . parseNonAllNullarySum opts
     {-# INLINE parseSum #-}
 
-instance ( FromPair           (a :+: b)
-         , FromObjectWithType (a :+: b) ) => ParseSum (a :+: b) False where
+instance ( FromPair         (a :+: b)
+         , FromTaggedObject (a :+: b) ) => ParseSum (a :+: b) False where
     parseSum opts = Tagged . parseNonAllNullarySum opts
     {-# INLINE parseSum #-}
 
     parseSumFromString opts key | key == name = Just $ M1 U1
                                 | otherwise   = Nothing
         where
-          name = pack $ constructorNameModifier opts $
+          name = pack $ constructorTagModifier opts $
                           conName (undefined :: t c U1 p)
     {-# INLINE parseSumFromString #-}
 
 --------------------------------------------------------------------------------
 
 parseNonAllNullarySum :: ( FromPair                       (a :+: b)
-                         , FromObjectWithType             (a :+: b)
+                         , FromTaggedObject               (a :+: b)
                          ) => Options -> Value -> Parser ((a :+: b) c)
 parseNonAllNullarySum opts =
     case sumEncoding opts of
-      ObjectWithType{..}    ->
+      TaggedObject{..} ->
           withObject "Object" $ \obj -> do
-            key <- obj .: pack typeFieldName
-            fromMaybe (notFound $ unpack key) $
-              parseFromObjectWithType opts contentsFieldName obj key
+            tag <- obj .: pack tagFieldName
+            fromMaybe (notFound $ unpack tag) $
+              parseFromTaggedObject opts contentsFieldName obj tag
 
       ObjectWithSingleField ->
           withObject "Object" $ \obj ->
             case H.toList obj of
-              [keyVal@(key, _)] -> fromMaybe (notFound $ unpack key) $
-                                     parsePair opts keyVal
+              [pair@(tag, _)] -> fromMaybe (notFound $ unpack tag) $
+                                   parsePair opts pair
               _ -> fail "Object doesn't have a single field"
 
       TwoElemArray ->
           withArray "Array" $ \arr ->
             if V.length arr == 2
             then case V.unsafeIndex arr 0 of
-                   String key -> fromMaybe (notFound $ unpack key) $
-                                   parsePair opts (key, V.unsafeIndex arr 1)
+                   String tag -> fromMaybe (notFound $ unpack tag) $
+                                   parsePair opts (tag, V.unsafeIndex arr 1)
                    _ -> fail "First element is not a String"
             else fail "Array doesn't have 2 elements"
 {-# INLINE parseNonAllNullarySum #-}
 
 --------------------------------------------------------------------------------
 
-class FromObjectWithType f where
-    parseFromObjectWithType :: Options -> String -> Object -> Text
-                            -> Maybe (Parser (f a))
+class FromTaggedObject f where
+    parseFromTaggedObject :: Options -> String -> Object -> Text
+                          -> Maybe (Parser (f a))
 
-instance (FromObjectWithType a, FromObjectWithType b) =>
-    FromObjectWithType (a :+: b) where
-        parseFromObjectWithType opts contentsFieldName obj key =
-            (fmap L1 <$> parseFromObjectWithType opts contentsFieldName obj key) <|>
-            (fmap R1 <$> parseFromObjectWithType opts contentsFieldName obj key)
-        {-# INLINE parseFromObjectWithType #-}
+instance (FromTaggedObject a, FromTaggedObject b) =>
+    FromTaggedObject (a :+: b) where
+        parseFromTaggedObject opts contentsFieldName obj tag =
+            (fmap L1 <$> parseFromTaggedObject opts contentsFieldName obj tag) <|>
+            (fmap R1 <$> parseFromTaggedObject opts contentsFieldName obj tag)
+        {-# INLINE parseFromTaggedObject #-}
 
-instance ( FromObjectWithType' f
-         , Constructor c ) => FromObjectWithType (C1 c f) where
-    parseFromObjectWithType opts contentsFieldName obj key
-        | key == name = Just $ M1 <$> parseFromObjectWithType'
+instance ( FromTaggedObject' f
+         , Constructor c ) => FromTaggedObject (C1 c f) where
+    parseFromTaggedObject opts contentsFieldName obj tag
+        | tag == name = Just $ M1 <$> parseFromTaggedObject'
                                         opts contentsFieldName obj
         | otherwise = Nothing
         where
-          name = pack $ constructorNameModifier opts $
+          name = pack $ constructorTagModifier opts $
                           conName (undefined :: t c f p)
-    {-# INLINE parseFromObjectWithType #-}
+    {-# INLINE parseFromTaggedObject #-}
 
 --------------------------------------------------------------------------------
 
-class FromObjectWithType' f where
-    parseFromObjectWithType' :: Options -> String -> Object -> Parser (f a)
+class FromTaggedObject' f where
+    parseFromTaggedObject' :: Options -> String -> Object -> Parser (f a)
 
-class FromObjectWithType'' f isRecord where
-    parseFromObjectWithType'' :: Options -> String -> Object
-                              -> Tagged isRecord (Parser (f a))
+class FromTaggedObject'' f isRecord where
+    parseFromTaggedObject'' :: Options -> String -> Object
+                            -> Tagged isRecord (Parser (f a))
 
-instance ( IsRecord               f isRecord
-         , FromObjectWithType''   f isRecord
-         ) => FromObjectWithType' f where
-    parseFromObjectWithType' opts contentsFieldName =
+instance ( IsRecord             f isRecord
+         , FromTaggedObject''   f isRecord
+         ) => FromTaggedObject' f where
+    parseFromTaggedObject' opts contentsFieldName =
         (unTagged :: Tagged isRecord (Parser (f a)) -> Parser (f a)) .
-        parseFromObjectWithType'' opts contentsFieldName
-    {-# INLINE parseFromObjectWithType' #-}
+        parseFromTaggedObject'' opts contentsFieldName
+    {-# INLINE parseFromTaggedObject' #-}
 
-instance (FromRecord f) => FromObjectWithType'' f True where
-    parseFromObjectWithType'' opts _ = Tagged . parseRecord opts
-    {-# INLINE parseFromObjectWithType'' #-}
+instance (FromRecord f) => FromTaggedObject'' f True where
+    parseFromTaggedObject'' opts _ = Tagged . parseRecord opts
+    {-# INLINE parseFromTaggedObject'' #-}
 
-instance (GFromJSON f) => FromObjectWithType'' f False where
-    parseFromObjectWithType'' opts contentsFieldName = Tagged .
+instance (GFromJSON f) => FromTaggedObject'' f False where
+    parseFromTaggedObject'' opts contentsFieldName = Tagged .
       (gParseJSON opts <=< (.: pack contentsFieldName))
-    {-# INLINE parseFromObjectWithType'' #-}
+    {-# INLINE parseFromTaggedObject'' #-}
 
 --------------------------------------------------------------------------------
 
     parsePair :: Options -> Pair -> Maybe (Parser (f a))
 
 instance (FromPair a, FromPair b) => FromPair (a :+: b) where
-    parsePair opts keyVal = (fmap L1 <$> parsePair opts keyVal) <|>
-                            (fmap R1 <$> parsePair opts keyVal)
+    parsePair opts pair = (fmap L1 <$> parsePair opts pair) <|>
+                          (fmap R1 <$> parsePair opts pair)
     {-# INLINE parsePair #-}
 
 instance (Constructor c, GFromJSON a, ConsFromJSON a) => FromPair (C1 c a) where
-    parsePair opts (key, value)
-        | key == name = Just $ gParseJSON opts value
+    parsePair opts (tag, value)
+        | tag == tag' = Just $ gParseJSON opts value
         | otherwise   = Nothing
         where
-          name = pack $ constructorNameModifier opts $
+          tag' = pack $ constructorTagModifier opts $
                           conName (undefined :: t c a p)
     {-# INLINE parsePair #-}
 

Data/Aeson/Types/Internal.hs

     , Options(..)
     , SumEncoding(..)
     , defaultOptions
-    , defaultObjectWithType
+    , defaultTaggedObject
     ) where
 
 import Control.Applicative
     { fieldNameModifier :: String -> String
       -- ^ Function applied to field names.
       -- Handy for removing common record prefixes for example.
-    , constructorNameModifier :: String -> String
-      -- ^ Function applied to constructor names.
-      -- Handy for lower-casing constructor names for example.
+    , constructorTagModifier :: String -> String
+      -- ^ Function applied to constructor tags which could be handy
+      -- for lower-casing them for example.
     , nullaryToString :: Bool
-      -- ^ If 'True' the constructors of a datatype, with /all/ nullary
-      -- constructors, will be encoded to a string with the
-      -- constructor name. If 'False' the encoding will always follow
-      -- the `sumEncoding`.
+      -- ^ If 'True' the constructors of a datatype, with /all/
+      -- nullary constructors, will be encoded to just a string with
+      -- the constructor tag. If 'False' the encoding will always
+      -- follow the `sumEncoding`.
     , omitNothingFields :: Bool
       -- ^ If 'True' record fields with a 'Nothing' value will be
       -- omitted from the resulting object. If 'False' the resulting
 
 -- | Specifies how to encode constructors of a sum datatype.
 data SumEncoding =
-    ObjectWithType { typeFieldName     :: String
-                   , contentsFieldName :: String
-                   }
+    TaggedObject { tagFieldName      :: String
+                 , contentsFieldName :: String
+                 }
     -- ^ A constructor will be encoded to an object with a field
-    -- 'typeFieldName' which specifies the constructor name (modified
-    -- by the 'constructorNameModifier'). If the constructor is a
-    -- record the encoded record fields will be unpacked into this
-    -- object. So make sure that your record doesn't have a field with
-    -- the same name as the 'typeFieldName'. Otherwise the type gets
-    -- overwritten by that field! If the constructor is not a record
-    -- the encoded constructor contents will be stored under the
-    -- 'contentsFieldName' field.
+    -- 'tagFieldName' which specifies the constructor tag (modified by
+    -- the 'constructorTagModifier'). If the constructor is a record
+    -- the encoded record fields will be unpacked into this object. So
+    -- make sure that your record doesn't have a field with the same
+    -- label as the 'tagFieldName'. Otherwise the tag gets overwritten
+    -- by the encoded value of that field! If the constructor is not a
+    -- record the encoded constructor contents will be stored under
+    -- the 'contentsFieldName' field.
   | ObjectWithSingleField
     -- ^ A constructor will be encoded to an object with a single
-    -- field named after the constructor (modified by the
-    -- 'constructorNameModifier') which maps to the encoded contents
-    -- of the constructor.
+    -- field named after the constructor tag (modified by the
+    -- 'constructorTagModifier') which maps to the encoded contents of
+    -- the constructor.
   | TwoElemArray
     -- ^ A constructor will be encoded to a 2-element array where the
-    -- first element is the name of the constructor (modified by the
-    -- 'constructorNameModifier') and the second element the encoded
+    -- first element is the tag of the constructor (modified by the
+    -- 'constructorTagModifier') and the second element the encoded
     -- contents of the constructor.
 
 -- | Default encoding 'Options':
 -- @
 -- 'Options'
 -- { 'fieldNameModifier'       = id
--- , 'constructorNameModifier' = id
+-- , 'constructorTagModifier'  = id
 -- , 'nullaryToString'         = True
 -- , 'omitNothingFields'       = False
--- , 'sumEncoding'             = 'defaultObjectWithType'
+-- , 'sumEncoding'             = 'defaultTaggedObject'
 -- }
 -- @
 defaultOptions :: Options
 defaultOptions = Options
                  { fieldNameModifier       = id
-                 , constructorNameModifier = id
+                 , constructorTagModifier  = id
                  , nullaryToString         = True
                  , omitNothingFields       = False
-                 , sumEncoding             = defaultObjectWithType
+                 , sumEncoding             = defaultTaggedObject
                  }
 
--- | Default 'ObjectWithType' 'SumEncoding' options:
+-- | Default 'TaggedObject' 'SumEncoding' options:
 --
 -- @
--- defaultObjectWithType = 'ObjectWithType'
---                         { 'typeFieldName'     = \"type\"
---                         , 'contentsFieldName' = \"contents\"
---                         }
+-- defaultTaggedObject = 'TaggedObject'
+--                       { 'tagFieldName'      = \"tag\"
+--                       , 'contentsFieldName' = \"contents\"
+--                       }
 -- @
-defaultObjectWithType :: SumEncoding
-defaultObjectWithType = ObjectWithType
-                        { typeFieldName     = "type"
-                        , contentsFieldName = "contents"
-                        }
+defaultTaggedObject :: SumEncoding
+defaultTaggedObject = TaggedObject
+                      { tagFieldName      = "tag"
+                      , contentsFieldName = "contents"
+                      }