@hackage superconstraints0.0.2
Access an instance's constraints
Categories
License
BSD-3-Clause
Maintainer
Ryan Trinkle <ryan.trinkle@gmail.com>
Links
Versions
Installation
Dependencies (8)
- base >=4.9.1 && <4.10
- constraints >=0.9.1 && <0.10
- containers >=0.5.7.1 && <0.6
- haskell-src-meta >=0.7.0.1 && <0.8
- mtl >=2.2.1 && <2.3
- tagged >=0.8.5 && <0.9 Show all…
Dependents (1)
@hackage/acme-everything
superconstraints
A way of inferring instance constraints given an instance.
Suppose you have a class like this:
class C a
instance C a => C [a]
Normally, given C [a], you cannot obtain C a; however, superconstraints allows you to add that capability:
class HasSuper (C a) => C a
instance C a => C [a]
makeSuper "C [a]"
Then, you can retrieve the superconstraint by doing:
case super (Proxy :: Proxy (C [a])) of
Dict -> ...
The superconstraint dictionary will include all of the constraints required by the instance.
Future Improvements
- Replace the crazy string argument to
makeSuperwith something more sensible