GHC.Magic.Dict

ghc-prim-0.11.0: GHC primitives

Copyright | (c) The University of Glasgow 2009
License | see libraries/ghc-prim/LICENSE
Maintainer | ghc-devs@haskell.org
Stability | internal
Portability | non-portable (GHC Extensions)
Safe Haskell | Unsafe
Language | Haskell2010

GHC.Magic.Dict

Description

Defines the `withDict` function. For more information, see `Note [withDict]` in GHC.Tc.Instance.Class in GHC. The definition of `withDict` is located in a separate module from GHC.Magic because `withDict` is `Unsafe` (it threatens type class coherence) while GHC.Magic is `Trustworthy`.

Use GHC.Exts from the `base` package instead of importing this module directly.

Synopsis

- class WithDict cls meth where
  - withDict :: forall {rr :: RuntimeRep} (r :: TYPE rr). meth -> (cls => r) -> r

# Documentation

class WithDict cls meth where Source #

The constraint ``WithDict` cls meth` can be solved when evidence for the constraint `cls` can be provided in the form of a dictionary of type `meth`. This requires `cls` to be a class constraint whose single method has type `meth`.

For more (important) details on how this works, see `Note [withDict]` in GHC.Tc.Instance.Class in GHC.

Since: ghc-prim-0.9.0

Methods

withDict :: forall {rr :: RuntimeRep} (r :: TYPE rr). meth -> (cls => r) -> r Source #