first-class-instances-1.0.0.0: First class typeclass instances
Safe HaskellNone
LanguageHaskell2010

FCI.Unsafe

Description

Reify first-class instances as constraints.

Use at your own risk.

Synopsis

Documentation

(==>) :: 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.