feat: Ability to specify integer definitions

This commit is contained in:
vegowotenks 2025-08-12 10:12:46 +02:00
parent 4bd766027f
commit bf525c2dfd
11 changed files with 142 additions and 12 deletions

22
src/Data/Map/Implicit.hs Normal file
View file

@ -0,0 +1,22 @@
{-# LANGUAGE Safe #-}
{-# LANGUAGE TypeFamilies #-}
--
-- | 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
type ImplicitMap :: Type -> Type
type role ImplicitMap nominal
newtype ImplicitMap v = ImplicitMap { get :: Map (KeyType v) v }
type ImplicitKeyOf :: Type -> Constraint
class ImplicitKeyOf v where
type KeyType v :: Type
keyOf :: v -> KeyType v
empty :: ImplicitMap v
empty = ImplicitMap Map.empty