on master help sign in
Also define the toEncoding method for the ToJSON instance of Ordering
91ec3beBas van Dijk
Data/Aeson/Types/Instances.hs+8−4
@@ -185,10 +185,14 @@ instance FromJSON Bool where
185 {-# INLINE parseJSON #-}
185 {-# INLINE parseJSON #-}
186
186
187instance ToJSON Ordering where
187instance ToJSON Ordering where
188− toJSON o = String $ case o of
188+ toJSON = toJSON . orderingToText
189+ toEncoding = toEncoding . orderingToText
190+
191+orderingToText :: Ordering -> T.Text
192+orderingToText o = case o of
189− LT -> "LT"
193+ LT -> "LT"
190− EQ -> "EQ"
194+ EQ -> "EQ"
191− GT -> "GT"
195+ GT -> "GT"
192
196
193instance FromJSON Ordering where
197instance FromJSON Ordering where
194 parseJSON = withText "Ordering" $ \s ->
198 parseJSON = withText "Ordering" $ \s ->
changelog.md+2
@@ -12,6 +12,8 @@
12
12
13* Added ToJSON and FromJSON instances for the Version type.
13* Added ToJSON and FromJSON instances for the Version type.
14
14
15+* Added ToJSON and FromJSON instances for the Ordering type.
16+
15
17
16# 0.10.0.0
18# 0.10.0.0
17
19