ghc-8.2.1: The GHC API

Safe HaskellNone
LanguageHaskell2010

TcDerivUtils

Synopsis

Documentation

data DerivSpec theta Source #

Instances

Outputable theta => Outputable (DerivSpec theta) Source # 

Methods

ppr :: DerivSpec theta -> SDoc Source #

pprPrec :: Rational -> DerivSpec theta -> SDoc Source #

data PredOrigin Source #

A PredType annotated with the origin of the constraint CtOrigin, and whether or the constraint deals in types or kinds.

data ThetaOrigin Source #

A list of wanted PredOrigin constraints (to_wanted_origins) alongside any corresponding given constraints (to_givens) and locally quantified type variables (to_tvs).

In most cases, to_givens will be empty, as most deriving mechanisms (e.g., stock and newtype deriving) do not require given constraints. The exception is DeriveAnyClass, which can involve given constraints. For example, if you tried to derive an instance for the following class using DeriveAnyClass:

class Foo a where
  bar :: a -> b -> String
  default bar :: (Show a, Ix b) => a -> b -> String
  bar = show

  baz :: Eq a => a -> a -> Bool
  default baz :: Ord a => a -> a -> Bool
  baz x y = compare x y == EQ

Then it would generate two ThetaOrigins, one for each method:

[ ThetaOrigin { to_tvs            = [b]
              , to_givens         = []
              , to_wanted_origins = [Show a, Ix b] }
, ThetaOrigin { to_tvs            = []
              , to_givens         = [Eq a]
              , to_wanted_origins = [Ord a] }
]