Safe Haskell | None |
---|---|
Language | Haskell2010 |
FCI.Internal
Description
Core types. This module is internal and provides no guarantees about stability and safety of its interface. It is left visible only as an escape hatch.
Documentation
type family Dict c = (t :: Type) | t -> c Source #
Type family that maps a constraint to its first class representation - should be generally used instead of its concrete result for consistency.
Instances
Reflect a constraint as a dictionary value.
You can use TypeApplications
to make the constraint c
explicit.
Dict
is injective, so c
may be inferred sometimes.
(==>) :: Dict c -> (c => r) -> r infixr 0 Source #
Reify a dictionary to resolve a constraint required by the second operand.
For example, this lets us use +
on a type that doesn't have a top-level
Num
instance.
>>>
newtype Foo = Foo Int deriving Show
>>>
(coerce (dict @(Num Int)) :: Dict (Num Foo)) ==> Foo 1 + Foo 2
Foo 3
This function is extremely unsafe. It breaks the global property that there is at most one instance for each constraint. For example, sets and maps in containers rely on that property to maintain their invariants.
Use at your own risk.