feat: Read and Show for all the types
This commit is contained in:
parent
bf525c2dfd
commit
fd715d99e0
9 changed files with 87 additions and 25 deletions
|
@ -1,17 +1,25 @@
|
|||
{-# LANGUAGE Safe #-}
|
||||
{-# LANGUAGE TypeFamilies #-}
|
||||
--
|
||||
{-# LANGUAGE StandaloneDeriving #-} -- specify instance contexts
|
||||
{-# LANGUAGE FlexibleContexts #-} -- use non type-variable argument in instance head
|
||||
{-# LANGUAGE UndecidableInstances #-} -- use type family in instance head
|
||||
-- | A Map that derives the keys for the mapping from the items.
|
||||
|
||||
module Data.Map.Implicit (ImplicitMap(), get, ImplicitKeyOf(..), empty) where
|
||||
import Data.Kind (Type, Constraint)
|
||||
import Data.Map (Map)
|
||||
import Data.Map qualified as Map
|
||||
import Text.Show (Show)
|
||||
import Text.Read (Read)
|
||||
import Data.Ord (Ord)
|
||||
|
||||
type ImplicitMap :: Type -> Type
|
||||
type role ImplicitMap nominal
|
||||
newtype ImplicitMap v = ImplicitMap { get :: Map (KeyType v) v }
|
||||
|
||||
deriving stock instance (Show (KeyType v), Show v) => Show (ImplicitMap v)
|
||||
deriving stock instance (Read (KeyType v), Ord (KeyType v), Read v) => Read (ImplicitMap v)
|
||||
|
||||
type ImplicitKeyOf :: Type -> Constraint
|
||||
|
||||
class ImplicitKeyOf v where
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue