feat: prettied up ImplicitMap show and read

This commit is contained in:
vegowotenks 2025-08-12 14:51:25 +02:00
parent d38c30e318
commit 9336a88cb9

View file

@ -24,7 +24,7 @@ newtype ImplicitMap v = ImplicitMap { get :: Map (KeyType v) v }
type ImplicitMapElems :: Type -> Type
type role ImplicitMapElems representational
newtype ImplicitMapElems v = ImplicitMapElems { elems :: [v] }
newtype ImplicitMapElems v = ImplicitMapElems [v]
deriving stock (Show, Read)
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
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
class ImplicitKeyOf v where