@@ -14,6 +14,7 @@
1414{-# LANGUAGE TypeOperators #-}
1515{-# LANGUAGE TypeSynonymInstances #-}
1616{-# LANGUAGE UndecidableInstances #-}
17+{-# LANGUAGE EmptyCase #-}
1718
1819#if __GLASGOW_HASKELL__ >= 706
1920{-# LANGUAGE PolyKinds #-}
@@ -91,6 +92,7 @@ import Data.Time.Format (FormatTime, formatTime)
9192import Data.Time.Locale.Compat (defaultTimeLocale)
9293import Data.Vector (Vector)
9394import Data.Version (Version, showVersion)
95+import Data.Void (Void)
9496import Data.Word (Word16, Word32, Word64, Word8)
9597import Foreign.Storable (Storable)
9698import Foreign.C.Types (CTime (..))
@@ -702,6 +704,12 @@ instance ( AllNullary (a :+: b) allNullary
702704-- possible but makes error messages a bit harder to understand for missing
703705-- instances.
704706
707+instance GToJSON Value arity V1 where
708+ -- Empty values do not exist, which makes the job of formatting them
709+ -- rather easy:
710+ gToJSON _ _ x = case x of {}
711+ {-# INLINE gToJSON #-}
712+
705713instance ToJSON a => GToJSON Value arity (K1 i a) where
706714 -- Constant values are encoded using their ToJSON instance:
707715 gToJSON _opts _ = toJSON . unK1
@@ -1221,6 +1229,13 @@ instance (ToJSON a, ToJSON b) => ToJSON (Either a b) where
12211229 toEncoding = toEncoding2
12221230 {-# INLINE toEncoding #-}
12231231
1232+instance ToJSON Void where
1233+ toJSON x = case x of {}
1234+ {-# INLINE toJSON #-}
1235+
1236+ toEncoding x = case x of {}
1237+ {-# INLINE toEncoding #-}
1238+
12241239
12251240instance ToJSON Bool where
12261241 toJSON = Bool