feat: prettied up ImplicitMap show and read
This commit is contained in:
parent
d38c30e318
commit
9336a88cb9
1 changed files with 2 additions and 2 deletions
|
@ -24,7 +24,7 @@ newtype ImplicitMap v = ImplicitMap { get :: Map (KeyType v) v }
|
||||||
|
|
||||||
type ImplicitMapElems :: Type -> Type
|
type ImplicitMapElems :: Type -> Type
|
||||||
type role ImplicitMapElems representational
|
type role ImplicitMapElems representational
|
||||||
newtype ImplicitMapElems v = ImplicitMapElems { elems :: [v] }
|
newtype ImplicitMapElems v = ImplicitMapElems [v]
|
||||||
deriving stock (Show, Read)
|
deriving stock (Show, Read)
|
||||||
|
|
||||||
instance (Show v) => Show (ImplicitMap v) where
|
instance (Show v) => Show (ImplicitMap v) where
|
||||||
|
@ -33,7 +33,7 @@ instance (Show v) => Show (ImplicitMap v) where
|
||||||
|
|
||||||
instance (Read v, ImplicitKeyOf v, Ord (KeyType v)) => Read (ImplicitMap v) where
|
instance (Read v, ImplicitKeyOf v, Ord (KeyType v)) => Read (ImplicitMap v) where
|
||||||
readPrec :: ReadPrec (ImplicitMap v)
|
readPrec :: ReadPrec (ImplicitMap v)
|
||||||
readPrec = ImplicitMap . Map.fromList . List.map (keyOf &&& id) . elems <$> readPrec
|
readPrec = ImplicitMap . Map.fromList . List.map (keyOf &&& id) . (\(ImplicitMapElems es) -> es) <$> readPrec
|
||||||
|
|
||||||
type ImplicitKeyOf :: Type -> Constraint
|
type ImplicitKeyOf :: Type -> Constraint
|
||||||
class ImplicitKeyOf v where
|
class ImplicitKeyOf v where
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue