{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MonoLocalBinds #-}
{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving ,DeriveGeneric #-}
{-# LANGUAGE CPP #-}
module Flat.Instances.Containers (sizeMap
, encodeMap
, decodeMap
) where
import Flat.Instances.Util
import Data.Map
import Flat.Instances.Base()
import Flat.Instances.Mono
import Data.Tree
import Data.Set
import Data.IntMap
import Data.Sequence
instance Flat a => Flat (IntMap a) where
size :: IntMap a -> NumBits -> NumBits
size = IntMap a -> NumBits -> NumBits
forall r.
(Flat (ContainerKey r), Flat (MapValue r), IsMap r) =>
Size r
sizeMap
encode :: IntMap a -> Encoding
encode = IntMap a -> Encoding
forall map.
(Flat (ContainerKey map), Flat (MapValue map), IsMap map) =>
map -> Encoding
encodeMap
decode :: Get (IntMap a)
decode = Get (IntMap a)
forall map.
(Flat (ContainerKey map), Flat (MapValue map), IsMap map) =>
Get map
decodeMap
instance (Flat a, Flat b, Ord a) => Flat (Map a b) where
size :: Map a b -> NumBits -> NumBits
size = Map a b -> NumBits -> NumBits
forall r.
(Flat (ContainerKey r), Flat (MapValue r), IsMap r) =>
Size r
sizeMap
encode :: Map a b -> Encoding
encode = Map a b -> Encoding
forall map.
(Flat (ContainerKey map), Flat (MapValue map), IsMap map) =>
map -> Encoding
encodeMap
decode :: Get (Map a b)
decode = Get (Map a b)
forall map.
(Flat (ContainerKey map), Flat (MapValue map), IsMap map) =>
Get map
decodeMap
instance Flat a => Flat (Seq a) where
size :: Seq a -> NumBits -> NumBits
size = Seq a -> NumBits -> NumBits
forall mono.
(MonoFoldable mono, Flat (Element mono)) =>
mono -> NumBits -> NumBits
sizeList
encode :: Seq a -> Encoding
encode = Seq a -> Encoding
forall mono.
(Flat (Element mono), MonoFoldable mono) =>
mono -> Encoding
encodeList
decode :: Get (Seq a)
decode = [a] -> Seq a
forall a. [a] -> Seq a
Data.Sequence.fromList ([a] -> Seq a) -> Get [a] -> Get (Seq a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get [a]
forall b. (IsSequence b, Flat (Element b)) => Get b
decodeList
instance (Flat a,Ord a) => Flat (Set a) where
size :: Set a -> NumBits -> NumBits
size = Set a -> NumBits -> NumBits
forall set. (IsSet set, Flat (Element set)) => Size set
sizeSet
encode :: Set a -> Encoding
encode = Set a -> Encoding
forall set. (IsSet set, Flat (Element set)) => set -> Encoding
encodeSet
decode :: Get (Set a)
decode = Get (Set a)
forall set. (IsSet set, Flat (Element set)) => Get set
decodeSet
#if ! MIN_VERSION_containers(0,5,8)
deriving instance Generic (Tree a)
#endif
instance (Flat a) => Flat (Tree a)