feat: instances for Ratio a and Map k v
This commit is contained in:
parent
a7bff630fc
commit
5e91f4b67e
1 changed files with 12 additions and 0 deletions
|
@ -42,6 +42,9 @@ import qualified Data.Set as Set
|
|||
import Data.ByteString.Lazy (LazyByteString)
|
||||
import Data.ByteString (ByteString)
|
||||
import Data.Maybe (fromMaybe)
|
||||
import Data.Map (Map)
|
||||
import qualified Data.Map as Map
|
||||
import Data.Ratio (Ratio)
|
||||
|
||||
type Indentation = Word
|
||||
|
||||
|
@ -187,6 +190,7 @@ deriving via ShowPrettySerialize Word32 instance PrettySerialize Word32
|
|||
deriving via ShowPrettySerialize Word64 instance PrettySerialize Word64
|
||||
deriving via ShowPrettySerialize Integer instance PrettySerialize Integer
|
||||
deriving via ShowPrettySerialize Natural instance PrettySerialize Natural
|
||||
deriving via ShowPrettySerialize (Ratio a) instance Show a => PrettySerialize (Ratio a)
|
||||
|
||||
-- text
|
||||
deriving via ShowPrettySerialize Text instance PrettySerialize Text
|
||||
|
@ -236,6 +240,13 @@ instance ExtractMappings (List a) where
|
|||
keyValuePairs :: [a] -> [(KeyType [a], ValueType [a])]
|
||||
keyValuePairs = zip [0..]
|
||||
|
||||
instance ExtractMappings (Map k v) where
|
||||
type KeyType (Map k v) = k
|
||||
type ValueType (Map k v) = v
|
||||
|
||||
keyValuePairs :: Map k v -> [(KeyType (Map k v), ValueType (Map k v))]
|
||||
keyValuePairs = Map.toList
|
||||
|
||||
newtype KeyValueSerialize a = KeyValueSerialize a
|
||||
|
||||
|
||||
|
@ -249,6 +260,7 @@ instance (ExtractMappings a, Typeable a, PrettySerialize (KeyType a), PrettySeri
|
|||
|
||||
deriving via KeyValueSerialize (Data.IArray.Array index element) instance (Data.IArray.Ix index, Typeable index, Typeable element, PrettySerialize index, PrettySerialize element) => PrettySerialize (Data.IArray.Array index element)
|
||||
deriving via KeyValueSerialize (List a) instance (Typeable a, PrettySerialize a) => PrettySerialize (List a)
|
||||
deriving via KeyValueSerialize (Map k v) instance (Typeable k, Typeable v, PrettySerialize k, PrettySerialize v) => PrettySerialize (Map k v)
|
||||
|
||||
|
||||
class GenericPrettySerialize self where
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue