-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Type-indexed maps -- -- Maps where keys are types and values can have types depending on their -- keys. -- -- @package type-map @version 0.1.2.0 module Data.TypeMap.Internal.Dynamic -- | Map from types t of kind * to values of type -- Item x t. newtype TypeMap x TypeMap :: (Map TypeRep Any) -> TypeMap x -- | An extensible type family mapping types (as keys) to types of values, -- parameterized by types x. -- | A constant mapping to type a. TypeMap -- (OfType a) is the type of maps from types to values of -- type a. data OfType a -- | Whether the map is empty. null :: TypeMap x -> Bool -- | The number of elements in the map. size :: TypeMap x -> Int -- | Empty type map. empty :: TypeMap x -- | Insert an element indexed by type t. insert :: forall t x proxy. Typeable t => proxy t -> Item x t -> TypeMap x -> TypeMap x -- | Lookup an element indexed by type t. lookup :: forall t x proxy. Typeable t => proxy t -> TypeMap x -> Maybe (Item x t) -- | Delete a key and its value from the map. Does nothing if the key does -- not exist. delete :: forall t x proxy. Typeable t => proxy t -> TypeMap x -> TypeMap x -- | Left-biased union of two maps; it keeps the first key if duplicates -- are found. union :: forall x. TypeMap x -> TypeMap x -> TypeMap x -- | Difference of two maps; keep elements of the first map which are not -- in the second. difference :: forall x. TypeMap x -> TypeMap x -> TypeMap x -- | Intersection of two maps; keep elements of the first map which are -- also in the second. intersection :: forall x y. TypeMap x -> TypeMap y -> TypeMap x -- | Map a function on all elements. map :: forall x y. (forall t. Typeable t => Proxy t -> Item x t -> Item y t) -> TypeMap x -> TypeMap y -- | Traverse the map. traverse :: forall f x y. Applicative f => (forall t. Typeable t => Proxy t -> Item x t -> f (Item y t)) -> TypeMap x -> f (TypeMap y) data ItemFun x y data ItemKleisli (f :: * -> *) x y withTypeRep :: forall x proxy. (forall t. Typeable t => Proxy t -> Typed x t) -> proxy x -> TypeRep -> UnTyped x module Data.TypeMap.Dynamic -- | Map from types t of kind * to values of type -- Item x t. data TypeMap x -- | An extensible type family mapping types (as keys) to types of values, -- parameterized by types x. -- | Empty type map. empty :: TypeMap x -- | Whether the map is empty. null :: TypeMap x -> Bool -- | The number of elements in the map. size :: TypeMap x -> Int -- | Insert an element indexed by type t. insert :: forall t x proxy. Typeable t => proxy t -> Item x t -> TypeMap x -> TypeMap x -- | Lookup an element indexed by type t. lookup :: forall t x proxy. Typeable t => proxy t -> TypeMap x -> Maybe (Item x t) -- | Delete a key and its value from the map. Does nothing if the key does -- not exist. delete :: forall t x proxy. Typeable t => proxy t -> TypeMap x -> TypeMap x -- | Left-biased union of two maps; it keeps the first key if duplicates -- are found. union :: forall x. TypeMap x -> TypeMap x -> TypeMap x -- | Difference of two maps; keep elements of the first map which are not -- in the second. difference :: forall x. TypeMap x -> TypeMap x -> TypeMap x -- | Intersection of two maps; keep elements of the first map which are -- also in the second. intersection :: forall x y. TypeMap x -> TypeMap y -> TypeMap x -- | Map a function on all elements. map :: forall x y. (forall t. Typeable t => Proxy t -> Item x t -> Item y t) -> TypeMap x -> TypeMap y -- | Traverse the map. traverse :: forall f x y. Applicative f => (forall t. Typeable t => Proxy t -> Item x t -> f (Item y t)) -> TypeMap x -> f (TypeMap y) -- | A constant mapping to type a. TypeMap -- (OfType a) is the type of maps from types to values of -- type a. data OfType a module Data.TypeMap.Internal.Dynamic.Alt -- | Insert an element indexed by type t. insert :: forall t x proxy. Typeable t => Item x t -> TypeMap x -> TypeMap x -- | Lookup an element indexed by type t. lookup :: forall t x proxy. Typeable t => TypeMap x -> Maybe (Item x t) -- | Delete a key and its value from the map. Does nothing if the key does -- not exist. delete :: forall t x proxy. Typeable t => TypeMap x -> TypeMap x map :: forall x y. (forall t. Typeable t => Item x t -> Item y t) -> TypeMap x -> TypeMap y traverse :: forall f x y. Applicative f => (forall t. Typeable t => Item x t -> f (Item y t)) -> TypeMap x -> f (TypeMap y) newtype Typed_ x t Typed_ :: (Typed x t) -> Typed_ x t withTypeRep :: forall x. (forall t. Typeable t => Typed_ x t) -> TypeRep -> UnTyped x -- | Type-application-based interface. module Data.TypeMap.Dynamic.Alt -- | Map from types t of kind * to values of type -- Item x t. data TypeMap x -- | An extensible type family mapping types (as keys) to types of values, -- parameterized by types x. -- | Empty type map. empty :: TypeMap x -- | Whether the map is empty. null :: TypeMap x -> Bool -- | The number of elements in the map. size :: TypeMap x -> Int -- | Insert an element indexed by type t. insert :: forall t x proxy. Typeable t => Item x t -> TypeMap x -> TypeMap x -- | Lookup an element indexed by type t. lookup :: forall t x proxy. Typeable t => TypeMap x -> Maybe (Item x t) -- | Delete a key and its value from the map. Does nothing if the key does -- not exist. delete :: forall t x proxy. Typeable t => TypeMap x -> TypeMap x -- | Left-biased union of two maps; it keeps the first key if duplicates -- are found. union :: forall x. TypeMap x -> TypeMap x -> TypeMap x -- | Difference of two maps; keep elements of the first map which are not -- in the second. difference :: forall x. TypeMap x -> TypeMap x -> TypeMap x -- | Intersection of two maps; keep elements of the first map which are -- also in the second. intersection :: forall x y. TypeMap x -> TypeMap y -> TypeMap x map :: forall x y. (forall t. Typeable t => Item x t -> Item y t) -> TypeMap x -> TypeMap y traverse :: forall f x y. Applicative f => (forall t. Typeable t => Item x t -> f (Item y t)) -> TypeMap x -> f (TypeMap y) -- | A constant mapping to type a. TypeMap -- (OfType a) is the type of maps from types to values of -- type a. data OfType a module Data.TypeMap.Internal.Unsafe -- | Index of type key a in association list d. -- | Type associated with a in d. If the key a -- occurs multiple times, the first one is used. -- | Append a type to a list. -- | Last element of a list. -- | All elements except the last one. -- | Helper to define index functions. unsafeIndex :: forall a d f m. (KnownNat (Index a d), Coercible (f Any) (m d)) => (forall c. f c -> Int -> c) -> m d -> Lookup a d -- | Helper to define cons functions. unsafeCons :: forall a d b f m. (Coercible (f Any) (m d), Coercible (f Any) (m ('(a, b) : d))) => (forall c. c -> f c -> f c) -> b -> m d -> m ('(a, b) : d) -- | Helper to define snoc functions. unsafeSnoc :: forall a d b f m. (Last d ~ '(a, b), Coercible (f Any) (m (Init d)), Coercible (f Any) (m d)) => (forall c. f c -> c -> f c) -> m (Init d) -> b -> m d module Data.TypeMap.Internal.Map -- | IntMap-backed type-map. data TypeMap d TypeMap :: !Int -> !(TypeMap' d) -> !Int -> TypeMap d newtype TypeMap' d TypeMap' :: (IntMap Any) -> TypeMap' d -- | Empty vector. empty :: TypeMap '[] -- | Access an element indexed by type a. O(log n) -- -- If a is associated to b in the type list d: -- --
--   index @a (v :: TypeMap d) :: b
--   
-- --
--   >>> let v = (0 :: Int) <| True <| "Hello" <| empty :: TypeMap '[ '("a", Int), '("b", Bool), '("c", String)]
--   
--   >>> index @"c" v
--   "Hello"
--   
index :: forall a d. KnownNat (Index a d) => TypeMap d -> Lookup a d -- | Add an element to the beginning of a map. O(log n) cons :: forall a d b. b -> TypeMap d -> TypeMap ('(a, b) : d) infixr 5 `cons` -- | Synonym of cons. (<|) :: forall a d b. b -> TypeMap d -> TypeMap ('(a, b) : d) infixr 5 <| -- | Add an element to the end of a list. O(log n) snoc :: forall a d b. (Last d ~ '(a, b)) => TypeMap (Init d) -> b -> TypeMap d infixl 5 `snoc` -- | Synonym of snoc. (|>) :: forall a d b. (Last d ~ '(a, b)) => TypeMap (Init d) -> b -> TypeMap d infixl 5 |> module Data.TypeMap.Internal.List -- | List-backed type-map. newtype TypeList d TypeList :: [Any] -> TypeList d -- | Empty list. empty :: TypeList '[] -- | Access an element indexed by its type a. O(n) -- -- If a is associated to b in the type list d: -- --
--   index @a (l :: TypeList d) :: b
--   
-- --
--   >>> let l = (0 :: Int) <| True <| "Hello" <| empty :: TypeList '[ '("a", Int), '("b", Bool), '("c", String)]
--   
--   >>> index @"c" l
--   "Hello"
--   
index :: forall a d. KnownNat (Index a d) => TypeList d -> Lookup a d -- | Add an element to the beginning of a list. O(1) cons :: forall a d b. b -> TypeList d -> TypeList ('(a, b) : d) infixr 5 `cons` -- | Synonym of cons. (<|) :: forall a d b. b -> TypeList d -> TypeList ('(a, b) : d) infixr 5 <| -- | Add an element to the end of a list. O(n) snoc :: forall a d b. (Last d ~ '(a, b)) => TypeList (Init d) -> b -> TypeList d infixr 5 `snoc` -- | Synonym of snoc. (|>) :: forall a d b. (Last d ~ '(a, b)) => TypeList (Init d) -> b -> TypeList d infixr 5 |> module Data.TypeMap.Internal.Vector -- | Vector-backed type-map. newtype TypeVector d TypeVector :: (Vector Any) -> TypeVector d -- | Empty vector. empty :: TypeVector '[] -- | Access an element indexed by type a. O(1) -- -- If a is associated to b in the type list d: -- --
--   index @a (v :: TypeVector d) :: b
--   
-- --
--   >>> let v = (0 :: Int) <| True <| "Hello" <| empty :: TypeVector '[ '("a", Int), '("b", Bool), '("c", String)]
--   
--   >>> index @"c" v
--   "Hello"
--   
index :: forall a d. KnownNat (Index a d) => TypeVector d -> Lookup a d -- | Add an element to the beginning of a vector. O(n) cons :: forall a d b. b -> TypeVector d -> TypeVector ('(a, b) : d) infixr 5 `cons` -- | Synonym of cons. (<|) :: forall a d b. b -> TypeVector d -> TypeVector ('(a, b) : d) infixr 5 <| -- | Add an element to the end of a vector. O(n) snoc :: forall a d b. (Last d ~ '(a, b)) => TypeVector (Init d) -> b -> TypeVector d infixr 5 `snoc` -- | Synonym of snoc. (|>) :: forall a d b. (Last d ~ '(a, b)) => TypeVector (Init d) -> b -> TypeVector d infixr 5 |> module Data.TypeMap.List -- | List-backed type-map. data TypeList d -- | Empty list. empty :: TypeList '[] -- | Access an element indexed by its type a. O(n) -- -- If a is associated to b in the type list d: -- --
--   index @a (l :: TypeList d) :: b
--   
-- --
--   >>> let l = (0 :: Int) <| True <| "Hello" <| empty :: TypeList '[ '("a", Int), '("b", Bool), '("c", String)]
--   
--   >>> index @"c" l
--   "Hello"
--   
index :: forall a d. KnownNat (Index a d) => TypeList d -> Lookup a d -- | Add an element to the beginning of a list. O(1) cons :: forall a d b. b -> TypeList d -> TypeList ('(a, b) : d) infixr 5 `cons` -- | Synonym of cons. (<|) :: forall a d b. b -> TypeList d -> TypeList ('(a, b) : d) infixr 5 <| -- | Add an element to the end of a list. O(n) snoc :: forall a d b. (Last d ~ '(a, b)) => TypeList (Init d) -> b -> TypeList d infixr 5 `snoc` -- | Synonym of snoc. (|>) :: forall a d b. (Last d ~ '(a, b)) => TypeList (Init d) -> b -> TypeList d infixr 5 |> -- | Convert from a list to a vector. toVector :: TypeList d -> TypeVector d module Data.TypeMap.Map -- | IntMap-backed type-map. data TypeMap d -- | Empty vector. empty :: TypeMap '[] -- | Access an element indexed by type a. O(log n) -- -- If a is associated to b in the type list d: -- --
--   index @a (v :: TypeMap d) :: b
--   
-- --
--   >>> let v = (0 :: Int) <| True <| "Hello" <| empty :: TypeMap '[ '("a", Int), '("b", Bool), '("c", String)]
--   
--   >>> index @"c" v
--   "Hello"
--   
index :: forall a d. KnownNat (Index a d) => TypeMap d -> Lookup a d -- | Add an element to the beginning of a map. O(log n) cons :: forall a d b. b -> TypeMap d -> TypeMap ('(a, b) : d) infixr 5 `cons` -- | Synonym of cons. (<|) :: forall a d b. b -> TypeMap d -> TypeMap ('(a, b) : d) infixr 5 <| -- | Add an element to the end of a list. O(log n) snoc :: forall a d b. (Last d ~ '(a, b)) => TypeMap (Init d) -> b -> TypeMap d infixl 5 `snoc` -- | Synonym of snoc. (|>) :: forall a d b. (Last d ~ '(a, b)) => TypeMap (Init d) -> b -> TypeMap d infixl 5 |> module Data.TypeMap.Static -- | Index of type key a in association list d. -- | Type associated with a in d. If the key a -- occurs multiple times, the first one is used. -- | Last element of a list. -- | All elements except the last one. module Data.TypeMap.Vector -- | Vector-backed type-map. data TypeVector d -- | Empty vector. empty :: TypeVector '[] -- | Access an element indexed by type a. O(1) -- -- If a is associated to b in the type list d: -- --
--   index @a (v :: TypeVector d) :: b
--   
-- --
--   >>> let v = (0 :: Int) <| True <| "Hello" <| empty :: TypeVector '[ '("a", Int), '("b", Bool), '("c", String)]
--   
--   >>> index @"c" v
--   "Hello"
--   
index :: forall a d. KnownNat (Index a d) => TypeVector d -> Lookup a d -- | Add an element to the beginning of a vector. O(n) cons :: forall a d b. b -> TypeVector d -> TypeVector ('(a, b) : d) infixr 5 `cons` -- | Synonym of cons. (<|) :: forall a d b. b -> TypeVector d -> TypeVector ('(a, b) : d) infixr 5 <| -- | Add an element to the end of a vector. O(n) snoc :: forall a d b. (Last d ~ '(a, b)) => TypeVector (Init d) -> b -> TypeVector d infixr 5 `snoc` -- | Synonym of snoc. (|>) :: forall a d b. (Last d ~ '(a, b)) => TypeVector (Init d) -> b -> TypeVector d infixr 5 |> -- | Convert from a vector to a list. toList :: TypeVector d -> TypeList l