@@ -755,6 +755,7 @@ instance ( GetConName f
755 , TaggedObjectPairs arity f
755 , TaggedObjectPairs arity f
756 , ObjectWithSingleFieldObj arity f
756 , ObjectWithSingleFieldObj arity f
757 , TwoElemArrayObj arity f
757 , TwoElemArrayObj arity f
758+ , UntaggedValueObj arity f
758 ) => SumToJSON arity f True where
759 ) => SumToJSON arity f True where
759 sumToJSON opts targs
760 sumToJSON opts targs
760 | allNullaryToStringTag opts = Tagged . String . pack
761 | allNullaryToStringTag opts = Tagged . String . pack
@@ -764,12 +765,14 @@ instance ( GetConName f
764instance ( TwoElemArrayObj arity f
765instance ( TwoElemArrayObj arity f
765 , TaggedObjectPairs arity f
766 , TaggedObjectPairs arity f
766 , ObjectWithSingleFieldObj arity f
767 , ObjectWithSingleFieldObj arity f
768+ , UntaggedValueObj arity f
767 ) => SumToJSON arity f False where
769 ) => SumToJSON arity f False where
768 sumToJSON opts targs = Tagged . nonAllNullarySumToJSON opts targs
770 sumToJSON opts targs = Tagged . nonAllNullarySumToJSON opts targs
770nonAllNullarySumToJSON :: ( TwoElemArrayObj arity f
772nonAllNullarySumToJSON :: ( TwoElemArrayObj arity f
771 , TaggedObjectPairs arity f
773 , TaggedObjectPairs arity f
772 , ObjectWithSingleFieldObj arity f
774 , ObjectWithSingleFieldObj arity f
775+ , UntaggedValueObj arity f
773 ) => Options -> ToArgs Value arity a
776 ) => Options -> ToArgs Value arity a
774 -> f a -> Value
777 -> f a -> Value
775nonAllNullarySumToJSON opts targs =
778nonAllNullarySumToJSON opts targs =
@@ -778,6 +781,7 @@ nonAllNullarySumToJSON opts targs =
778 object . taggedObjectPairs opts targs tagFieldName contentsFieldName
781 object . taggedObjectPairs opts targs tagFieldName contentsFieldName
779 ObjectWithSingleField -> Object . objectWithSingleFieldObj opts targs
782 ObjectWithSingleField -> Object . objectWithSingleFieldObj opts targs
780 TwoElemArray -> Array . twoElemArrayObj opts targs
783 TwoElemArray -> Array . twoElemArrayObj opts targs
784+ UntaggedValue -> untaggedValueObj opts targs
782--------------------------------------------------------------------------------
786--------------------------------------------------------------------------------
@@ -789,6 +793,7 @@ instance ( GetConName f
789 , TaggedObjectEnc arity f
793 , TaggedObjectEnc arity f
790 , ObjectWithSingleFieldEnc arity f
794 , ObjectWithSingleFieldEnc arity f
791 , TwoElemArrayEnc arity f
795 , TwoElemArrayEnc arity f
796+ , UntaggedValueEnc arity f
792 ) => SumToEncoding arity f True where
797 ) => SumToEncoding arity f True where
793 sumToEncoding opts targs
798 sumToEncoding opts targs
794 | allNullaryToStringTag opts = Tagged . toEncoding .
799 | allNullaryToStringTag opts = Tagged . toEncoding .
@@ -798,12 +803,14 @@ instance ( GetConName f
798instance ( TwoElemArrayEnc arity f
803instance ( TwoElemArrayEnc arity f
799 , TaggedObjectEnc arity f
804 , TaggedObjectEnc arity f
800 , ObjectWithSingleFieldEnc arity f
805 , ObjectWithSingleFieldEnc arity f
806+ , UntaggedValueEnc arity f
801 ) => SumToEncoding arity f False where
807 ) => SumToEncoding arity f False where
802 sumToEncoding opts targs = Tagged . nonAllNullarySumToEncoding opts targs
808 sumToEncoding opts targs = Tagged . nonAllNullarySumToEncoding opts targs
804nonAllNullarySumToEncoding :: ( TwoElemArrayEnc arity f
810nonAllNullarySumToEncoding :: ( TwoElemArrayEnc arity f
805 , TaggedObjectEnc arity f
811 , TaggedObjectEnc arity f
806 , ObjectWithSingleFieldEnc arity f
812 , ObjectWithSingleFieldEnc arity f
813+ , UntaggedValueEnc arity f
807 ) => Options -> ToArgs Encoding arity a
814 ) => Options -> ToArgs Encoding arity a
808 -> f a -> Encoding
815 -> f a -> Encoding
809nonAllNullarySumToEncoding opts targs =
816nonAllNullarySumToEncoding opts targs =
@@ -812,6 +819,7 @@ nonAllNullarySumToEncoding opts targs =
812 taggedObjectEnc opts targs tagFieldName contentsFieldName
819 taggedObjectEnc opts targs tagFieldName contentsFieldName
813 ObjectWithSingleField -> objectWithSingleFieldEnc opts targs
820 ObjectWithSingleField -> objectWithSingleFieldEnc opts targs
814 TwoElemArray -> twoElemArrayEnc opts targs
821 TwoElemArray -> twoElemArrayEnc opts targs
822+ UntaggedValue -> untaggedValueEnc opts targs
816--------------------------------------------------------------------------------
824--------------------------------------------------------------------------------
@@ -1172,6 +1180,60 @@ instance ( GToEncoding arity a
1172 gToEncoding opts targs v ><
1180 gToEncoding opts targs v ><
1173 E.closeCurly
1181 E.closeCurly
1183+--------------------------------------------------------------------------------
1185+class UntaggedValueObj arity f where
1186+ untaggedValueObj :: Options -> ToArgs Value arity a
1190+ ( UntaggedValueObj arity a
1191+ , UntaggedValueObj arity b
1192+ ) => UntaggedValueObj arity (a :+: b)
1194+ untaggedValueObj opts targs (L1 x) = untaggedValueObj opts targs x
1195+ untaggedValueObj opts targs (R1 x) = untaggedValueObj opts targs x
1197+instance OVERLAPPABLE_
1199+ , ConsToJSON arity a
1200+ ) => UntaggedValueObj arity (C1 c a) where
1201+ untaggedValueObj = gToJSON
1203+instance OVERLAPPING_
1205+ => UntaggedValueObj arity (C1 c U1)
1207+ untaggedValueObj opts _ _ = toJSON $
1208+ constructorTagModifier opts $ conName (undefined :: t c U1 p)
1210+--------------------------------------------------------------------------------
1212+class UntaggedValueEnc arity f where
1213+ untaggedValueEnc :: Options -> ToArgs Encoding arity a
1216+ ( UntaggedValueEnc arity a
1217+ , UntaggedValueEnc arity b
1218+ ) => UntaggedValueEnc arity (a :+: b)
1220+ untaggedValueEnc opts targs (L1 x) = untaggedValueEnc opts targs x
1221+ untaggedValueEnc opts targs (R1 x) = untaggedValueEnc opts targs x
1223+instance OVERLAPPABLE_
1224+ ( GToEncoding arity a
1225+ , ConsToEncoding arity a
1226+ ) => UntaggedValueEnc arity (C1 c a)
1228+ untaggedValueEnc = gToEncoding
1230+instance OVERLAPPING_
1232+ => UntaggedValueEnc arity (C1 c U1)
1234+ untaggedValueEnc opts _ _ = toEncoding $
1235+ constructorTagModifier opts $ conName (undefined :: t c U1 p)
1175-------------------------------------------------------------------------------
1237-------------------------------------------------------------------------------
1176-- Instances
1238-- Instances
1177-------------------------------------------------------------------------------
1239-------------------------------------------------------------------------------