ghc-8.4.0.20180118: The GHC API

Safe HaskellNone
LanguageHaskell2010

TcDerivUtils

Synopsis

Documentation

type DerivM = ReaderT DerivEnv TcRn Source #

To avoid having to manually plumb everything in DerivEnv throughout various functions in TcDeriv and TcDerivInfer, we use DerivM, which is a simple reader around TcRn.

data DerivEnv Source #

Contains all of the information known about a derived instance when determining what its EarlyDerivSpec should be.

Constructors

DerivEnv 

Fields

Instances
Outputable DerivEnv # 
Instance details

data DerivSpec theta Source #

Instances
Outputable theta => Outputable (DerivSpec theta) # 
Instance details

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.

Instances
Outputable PredOrigin # 
Instance details

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] }
]
Instances
Outputable ThetaOrigin # 
Instance details