@@ -755,6 +755,7 @@ instance ( GetConName f
755755 , TaggedObjectPairs arity f
756756 , ObjectWithSingleFieldObj arity f
757757 , TwoElemArrayObj arity f
758+ , UntaggedValueObj arity f
758759 ) => SumToJSON arity f True where
759760 sumToJSON opts targs
760761 | allNullaryToStringTag opts = Tagged . String . pack
@@ -764,12 +765,14 @@ instance ( GetConName f
764765instance ( TwoElemArrayObj arity f
765766 , TaggedObjectPairs arity f
766767 , ObjectWithSingleFieldObj arity f
768+ , UntaggedValueObj arity f
767769 ) => SumToJSON arity f False where
768770 sumToJSON opts targs = Tagged . nonAllNullarySumToJSON opts targs
769771
770772nonAllNullarySumToJSON :: ( TwoElemArrayObj arity f
771773 , TaggedObjectPairs arity f
772774 , ObjectWithSingleFieldObj arity f
775+ , UntaggedValueObj arity f
773776 ) => Options -> ToArgs Value arity a
774777 -> f a -> Value
775778nonAllNullarySumToJSON opts targs =
@@ -778,6 +781,7 @@ nonAllNullarySumToJSON opts targs =
778781 object . taggedObjectPairs opts targs tagFieldName contentsFieldName
779782 ObjectWithSingleField -> Object . objectWithSingleFieldObj opts targs
780783 TwoElemArray -> Array . twoElemArrayObj opts targs
784+ UntaggedValue -> untaggedValueObj opts targs
781785
782786--------------------------------------------------------------------------------
783787
@@ -789,6 +793,7 @@ instance ( GetConName f
789793 , TaggedObjectEnc arity f
790794 , ObjectWithSingleFieldEnc arity f
791795 , TwoElemArrayEnc arity f
796+ , UntaggedValueEnc arity f
792797 ) => SumToEncoding arity f True where
793798 sumToEncoding opts targs
794799 | allNullaryToStringTag opts = Tagged . toEncoding .
@@ -798,12 +803,14 @@ instance ( GetConName f
798803instance ( TwoElemArrayEnc arity f
799804 , TaggedObjectEnc arity f
800805 , ObjectWithSingleFieldEnc arity f
806+ , UntaggedValueEnc arity f
801807 ) => SumToEncoding arity f False where
802808 sumToEncoding opts targs = Tagged . nonAllNullarySumToEncoding opts targs
803809
804810nonAllNullarySumToEncoding :: ( TwoElemArrayEnc arity f
805811 , TaggedObjectEnc arity f
806812 , ObjectWithSingleFieldEnc arity f
813+ , UntaggedValueEnc arity f
807814 ) => Options -> ToArgs Encoding arity a
808815 -> f a -> Encoding
809816nonAllNullarySumToEncoding opts targs =
@@ -812,6 +819,7 @@ nonAllNullarySumToEncoding opts targs =
812819 taggedObjectEnc opts targs tagFieldName contentsFieldName
813820 ObjectWithSingleField -> objectWithSingleFieldEnc opts targs
814821 TwoElemArray -> twoElemArrayEnc opts targs
822+ UntaggedValue -> untaggedValueEnc opts targs
815823
816824--------------------------------------------------------------------------------
817825
@@ -1172,6 +1180,60 @@ instance ( GToEncoding arity a
11721180 gToEncoding opts targs v ><
11731181 E.closeCurly
11741182
1183+--------------------------------------------------------------------------------
1184+
1185+class UntaggedValueObj arity f where
1186+ untaggedValueObj :: Options -> ToArgs Value arity a
1187+ -> f a -> Value
1188+
1189+instance
1190+ ( UntaggedValueObj arity a
1191+ , UntaggedValueObj arity b
1192+ ) => UntaggedValueObj arity (a :+: b)
1193+ where
1194+ untaggedValueObj opts targs (L1 x) = untaggedValueObj opts targs x
1195+ untaggedValueObj opts targs (R1 x) = untaggedValueObj opts targs x
1196+
1197+instance OVERLAPPABLE_
1198+ ( GToJSON arity a
1199+ , ConsToJSON arity a
1200+ ) => UntaggedValueObj arity (C1 c a) where
1201+ untaggedValueObj = gToJSON
1202+
1203+instance OVERLAPPING_
1204+ ( Constructor c )
1205+ => UntaggedValueObj arity (C1 c U1)
1206+ where
1207+ untaggedValueObj opts _ _ = toJSON $
1208+ constructorTagModifier opts $ conName (undefined :: t c U1 p)
1209+
1210+--------------------------------------------------------------------------------
1211+
1212+class UntaggedValueEnc arity f where
1213+ untaggedValueEnc :: Options -> ToArgs Encoding arity a
1214+ -> f a -> Encoding
1215+instance
1216+ ( UntaggedValueEnc arity a
1217+ , UntaggedValueEnc arity b
1218+ ) => UntaggedValueEnc arity (a :+: b)
1219+ where
1220+ untaggedValueEnc opts targs (L1 x) = untaggedValueEnc opts targs x
1221+ untaggedValueEnc opts targs (R1 x) = untaggedValueEnc opts targs x
1222+
1223+instance OVERLAPPABLE_
1224+ ( GToEncoding arity a
1225+ , ConsToEncoding arity a
1226+ ) => UntaggedValueEnc arity (C1 c a)
1227+ where
1228+ untaggedValueEnc = gToEncoding
1229+
1230+instance OVERLAPPING_
1231+ ( Constructor c )
1232+ => UntaggedValueEnc arity (C1 c U1)
1233+ where
1234+ untaggedValueEnc opts _ _ = toEncoding $
1235+ constructorTagModifier opts $ conName (undefined :: t c U1 p)
1236+
11751237-------------------------------------------------------------------------------
11761238-- Instances
11771239-------------------------------------------------------------------------------