th-typegraph-0.17: Graph of the subtype relation

Safe HaskellNone
LanguageHaskell2010

Language.Haskell.TH.TypeGraph.Expand

Description

The Expanded class helps keep track of which Type values have been fully expanded to a canonical form. This lets us use the Eq and Ord relationships on Type and Pred values when reasoning about instance context. What the expandType function does is use the function from th-desugar to replace occurrences of ConT name with the associated Type if name is a declared type synonym TySynD name _ typ. For convenience, a wrapper type E is provided, along with the Expanded instances E Type and E Pred. Now the expandType and expandPred functions can be used to return values of type E Type and E Pred respectively.

Instances Expanded Type Type and Expanded Pred Pred are provided in Language.Haskell.TH.Context.Unsafe, for when less type safety is required.

Synopsis

Documentation

class Expanded un ex | ex -> un where Source

This class lets us use the same expand* functions to work with specially marked expanded types or with the original types.

Methods

markExpanded Source

Arguments

:: un 
-> ex

Unsafely mark a value as expanded

runExpanded' Source

Arguments

:: ex 
-> un

Strip mark off an expanded value

runExpanded :: Expanded a (E a) => E a -> a Source

expandType :: (DsMonad m, Expanded Type e) => Type -> m e Source

Apply the th-desugar expand function to a Type and mark it as expanded.

expandPred :: (DsMonad m, Expanded Pred e) => Pred -> m e Source

Apply the th-desugar expand function to a Pred and mark it as expanded. Note that the definition of Pred changed in template-haskell-2.10.0.0.

expandClassP :: forall m e. (DsMonad m, Expanded Pred e) => Name -> [Type] -> m e Source

Expand a list of Type and build an expanded ClassP Pred.

newtype E a Source

A concrete type for which Expanded instances are declared below.

Constructors

E a 

Instances

Expanded Type (E Type) 
Expanded Pred (E Pred) 
Eq a => Eq (E a) 
Ord a => Ord (E a) 
Show a => Show (E a) 
Ppr a => Ppr (E a) 
Lift (E Type) 
Ppr (Maybe Field, E Type)