Commits

Bryan O'Sullivan committed 29bd25b

Add ToJSON and FromJSON instances for HashSet.

Comments (0)

Files changed (1)

Data/Aeson/Types.hs

 import qualified Data.ByteString as B
 import qualified Data.ByteString.Lazy as LB
 import qualified Data.HashMap.Strict as H
+import qualified Data.HashSet as HashSet
 import qualified Data.IntSet as IntSet
 import qualified Data.Map as M
 import qualified Data.Set as Set
     parseJSON = fmap Set.fromList . parseJSON
     {-# INLINE parseJSON #-}
 
+instance (ToJSON a) => ToJSON (HashSet.HashSet a) where
+    toJSON = toJSON . HashSet.toList
+    {-# INLINE toJSON #-}
+    
+instance (Eq a, Hashable a, FromJSON a) => FromJSON (HashSet.HashSet a) where
+    parseJSON = fmap HashSet.fromList . parseJSON
+    {-# INLINE parseJSON #-}
+
 instance ToJSON IntSet.IntSet where
     toJSON = toJSON . IntSet.toList
     {-# INLINE toJSON #-}