Safe Haskell | None |
---|
Documentation
The datatype of Keys.
- x
- The scope of this key. This can either be
T
for top-level keys created withcreateKey
or an existential type for keys introduced bywithKey
(or with the Key monadKeyM
). - a
- The type of things that can be sorted at this key.
For example, Key T Int
is a top-level key that can be used to store values
of type Int
in a heterogenous map.
withKey :: (forall x. HKey x a -> b) -> bSource
O(1). Scopes a key to the given function The key cannot escape the function (because of the existential type).
The implementation actually *creates* a key, but because the key cannot escape
the given function f
, there is no way to observe that if we run
withKey f
twice, that it will get a different key the second time.