@@ -182,6 +182,21 @@ instance FromJSON Bool where
182182 parseJSON = withBool "Bool" pure
183183 {-# INLINE parseJSON #-}
184184
185+instance ToJSON Ordering where
186+ toJSON o = String $ case o of
187+ LT -> "LT"
188+ EQ -> "EQ"
189+ GT -> "GT"
190+
191+instance FromJSON Ordering where
192+ parseJSON v = case v of
193+ String s -> case s of
194+ "LT" -> return LT
195+ "EQ" -> return EQ
196+ "GT" -> return GT
197+ _ -> fail "Parsing Ordering value failed: expected \"LT\", \"EQ\", or \"GT\""
198+ _ -> typeMismatch "Ordering" v
199+
185200instance ToJSON () where
186201 toJSON _ = emptyArray
187202 {-# INLINE toJSON #-}