-- 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.7.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. type family Item x t -- | 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 -- | Infix version of insert to facilitate a literal-ish syntax: -- --
--   empty
--     <: (Proxy k1, v1)
--     <: (Proxy k2, v2)
--   
(<:) :: forall t x proxy. Typeable t => TypeMap x -> (proxy t, Item x t) -> TypeMap x -- | Update an element indexed by type t. update :: forall t x proxy. Typeable t => proxy t -> (Item x t -> Maybe (Item x t)) -> TypeMap x -> TypeMap x -- | Update a (possibly absent) element indexed by type t. alter :: forall t x proxy. Typeable t => proxy t -> (Maybe (Item x t) -> Maybe (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 -- | Reduce a constant type map into a plain list of values. toList :: forall r. TypeMap (OfType r) -> [r] -- | Collapse a type map into a plain list of values. toListMap :: forall tm r. (forall t. Proxy t -> Item tm t -> r) -> TypeMap tm -> [r] -- | Traverse the type map. (map with effects.) 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) type family Typed x t type family UnTyped x 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. type family Item x t -- | 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 -- | Infix version of insert to facilitate a literal-ish syntax: -- --
--   empty
--     <: (Proxy k1, v1)
--     <: (Proxy k2, v2)
--   
(<:) :: forall t x proxy. Typeable t => TypeMap x -> (proxy t, Item x t) -> TypeMap x -- | Update an element indexed by type t. update :: forall t x proxy. Typeable t => proxy t -> (Item x t -> Maybe (Item x t)) -> TypeMap x -> TypeMap x -- | Update a (possibly absent) element indexed by type t. alter :: forall t x proxy. Typeable t => proxy t -> (Maybe (Item x t) -> Maybe (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 -- | 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 type map. (map with effects.) 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) -- | Reduce a constant type map into a plain list of values. toList :: forall r. TypeMap (OfType r) -> [r] -- | Collapse a type map into a plain list of values. toListMap :: forall tm r. (forall t. Proxy t -> Item tm t -> r) -> TypeMap tm -> [r] -- | 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 -- | 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. Typeable t => Item x t -> TypeMap x -> TypeMap x -- | Infix version of insert to facilitate a literal-ish syntax: -- --
--   empty
--     <: at t1 v1
--     <: at t2 v2
--   
(<:) :: forall t x proxy. Typeable t => TypeMap x -> (proxy t, Item x t) -> TypeMap x -- | See (<:). at :: forall t a. Typeable t => a -> (Proxy t, a) -- | Update an element indexed by type t. update :: forall t x. Typeable t => (Item x t -> Maybe (Item x t)) -> TypeMap x -> TypeMap x -- | Update a (possibly absent) element indexed by type t. alter :: forall t x. Typeable t => (Maybe (Item x t) -> Maybe (Item x t)) -> TypeMap x -> TypeMap x -- | Lookup an element indexed by type t. lookup :: forall t x. 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. Typeable t => TypeMap x -> TypeMap x -- | Map a function on all elements. map :: forall x y. (forall t. Typeable t => Item x t -> Item y t) -> TypeMap x -> TypeMap y -- | Traverse the type map. (map with effects.) 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. -- --
--   {-# LANGUAGE TypeApplications #-}
--   
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. type family Item x t -- | 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. Typeable t => Item x t -> TypeMap x -> TypeMap x -- | Infix version of insert to facilitate a literal-ish syntax: -- --
--   empty
--     <: at t1 v1
--     <: at t2 v2
--   
(<:) :: forall t x proxy. Typeable t => TypeMap x -> (proxy t, Item x t) -> TypeMap x -- | See (<:). at :: forall t a. Typeable t => a -> (Proxy t, a) -- | Update an element indexed by type t. update :: forall t x. Typeable t => (Item x t -> Maybe (Item x t)) -> TypeMap x -> TypeMap x -- | Update a (possibly absent) element indexed by type t. alter :: forall t x. Typeable t => (Maybe (Item x t) -> Maybe (Item x t)) -> TypeMap x -> TypeMap x -- | Lookup an element indexed by type t. lookup :: forall t x. 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. Typeable t => TypeMap x -> TypeMap x -- | Map a function on all elements. map :: forall x y. (forall t. Typeable t => Item x t -> Item y t) -> TypeMap x -> TypeMap y -- | Traverse the type map. (map with effects.) traverse :: forall f x y. Applicative f => (forall t. Typeable t => Item x t -> f (Item y t)) -> TypeMap x -> f (TypeMap y) -- | Reduce a constant type map into a plain list of values. toList :: forall r. TypeMap (OfType r) -> [r] -- | Collapse a type map into a plain list of values. toListMap :: forall tm r. (forall t. Proxy t -> Item tm t -> r) -> TypeMap tm -> [r] -- | 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 -- | 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 -- | All elements except the last one. type family Init (d :: [k]) -- | Last element of a list. type family Last (d :: [k]) -- | Append a type to a list. type family Snoc (d :: [k]) (a :: k) -- | Type associated with a in d. If the key a -- occurs multiple times, the first one is used. type family Lookup (a :: k) (d :: [(k, *)]) -- | Index of type key a in association list d. type family Index (a :: k) (d :: [(k, *)]) -- | 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 -- | This class gives the integer associated with a type-level natural. -- There are instances of the class for every concrete literal: 0, 1, 2, -- etc. class KnownNat (n :: Nat) -- | The type constructor Any is type to which you can unsafely -- coerce any lifted type, and back. More concretely, for a lifted type -- t and value x :: t, -- unsafeCoerce -- (unsafeCoerce x :: Any) :: t is equivalent to x. type family Any :: k unsafeCoerce :: a -> b -- | Proxy is a type that holds no data, but has a phantom parameter -- of arbitrary type (or even kind). Its use is to provide type -- information, even though there is no value available of that type (or -- it may be too costly to create one). -- -- Historically, Proxy :: Proxy a is a safer -- alternative to the undefined :: a idiom. -- --
--   >>> Proxy :: Proxy (Void, Int -> Int)
--   Proxy
--   
-- -- Proxy can even hold types of higher kinds, -- --
--   >>> Proxy :: Proxy Either
--   Proxy
--   
-- --
--   >>> Proxy :: Proxy Functor
--   Proxy
--   
-- --
--   >>> Proxy :: Proxy complicatedStructure
--   Proxy
--   
data Proxy (t :: k) Proxy :: Proxy (t :: k) 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 family Index (a :: k) (d :: [(k, *)]) -- | Type associated with a in d. If the key a -- occurs multiple times, the first one is used. type family Lookup (a :: k) (d :: [(k, *)]) -- | Last element of a list. type family Last (d :: [k]) -- | All elements except the last one. type family Init (d :: [k]) 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