module Flat.Instances.Unordered
  ()
where

import           Flat.Instances.Mono
import           Flat.Instances.Util
import           Data.HashSet
import           Data.Hashable
import qualified Data.HashMap.Strict           as MS

-- $setup
-- >>> import Flat.Instances.Base()
-- >>> import Flat.Instances.Test
-- >>> import Data.Word    
-- >>> import qualified Data.HashMap.Strict
-- >>> import qualified Data.HashMap.Lazy
-- >>> import qualified Data.HashSet
-- >>> let test = tstBits

{-|
>>> test (Data.HashSet.fromList [1..3::Word])
(True,28,"10000000 11000000 10100000 0110")
-}

instance (Hashable a, Eq a,Flat a) => Flat (HashSet a) where
  size :: HashSet a -> NumBits -> NumBits
size   = HashSet a -> NumBits -> NumBits
forall set. (IsSet set, Flat (Element set)) => Size set
sizeSet
  encode :: HashSet a -> Encoding
encode = HashSet a -> Encoding
forall set. (IsSet set, Flat (Element set)) => set -> Encoding
encodeSet
  decode :: Get (HashSet a)
decode = Get (HashSet a)
forall set. (IsSet set, Flat (Element set)) => Get set
decodeSet

{-|
>>> test (Data.HashMap.Strict.fromList [(1,11),(2,22)])
(True,35,"10000001 00001011 01000001 00001011 000")

>>> test (Data.HashMap.Lazy.fromList [(1,11),(2,22)])
(True,35,"10000001 00001011 01000001 00001011 000")

-}
instance (Hashable k,Eq k,Flat k,Flat v) => Flat (MS.HashMap k v) where
  size :: HashMap k v -> NumBits -> NumBits
size   = HashMap k v -> NumBits -> NumBits
forall r.
(Flat (ContainerKey r), Flat (MapValue r), IsMap r) =>
Size r
sizeMap
  encode :: HashMap k v -> Encoding
encode = HashMap k v -> Encoding
forall map.
(Flat (ContainerKey map), Flat (MapValue map), IsMap map) =>
map -> Encoding
encodeMap
  decode :: Get (HashMap k v)
decode = Get (HashMap k v)
forall map.
(Flat (ContainerKey map), Flat (MapValue map), IsMap map) =>
Get map
decodeMap

-- instance (Hashable k,Eq k,Flat k,Flat v) => Flat (ML.HashMap k v) where
--   size   = sizeMap
--   encode = encodeMap
--   decode = decodeMap