Copyright | (c) 2019 Artem Chirkin |
---|---|
License | BSD3 |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Extract a Constraint from a Dict to manipulate it as a plain value. It is supposed to be used in compiler plugins -- to move around instances of type classes.
Synopsis
- data BareConstraint :: Constraint -> Type
- pattern DictValue :: BareConstraint c -> Dict c
- dictToBare :: Dict c -> BareConstraint c
- bareToDict :: BareConstraint c -> Dict c
Documentation
data BareConstraint :: Constraint -> Type Source #
An unsafeCoerced pointer to a Constraint, such as a class function dictionary.
pattern DictValue :: BareConstraint c -> Dict c Source #
Extract the constraint inside the Dict GADT as if it was
an ordinary value of kind Type
.
It exploits the feature of the GHC core language -- representing constraints as ordinary type arguments of a function. Thus, I unsafeCoerce between a function with one argument and a function with no arguments and one constraint.
This pattern has never been tested with multiple constraints.
dictToBare :: Dict c -> BareConstraint c Source #
Extract a Constraint
from a Dict
bareToDict :: BareConstraint c -> Dict c Source #
Wrap a Constraint
into a Dict