haskell-tools-rewrite-0.5.0.0: Facilities for generating new parts of the Haskell-Tools AST

Safe HaskellNone
LanguageHaskell2010

Language.Haskell.Tools.AST.Match.Decls

Contents

Description

UPattern matching on declaration-level AST fragments for refactorings.

Synopsis

Declarations

pattern TypeDecl :: forall dom. DeclHead dom -> Type dom -> Decl dom Source #

A type synonym ( type String = [Char] )

pattern StandaloneDeriving :: forall dom. InstanceRule dom -> Decl dom Source #

Standalone deriving declaration ( deriving instance X T )

pattern FixityDecl :: forall dom. FixitySignature dom -> Decl dom Source #

Fixity declaration ( infixl 5 +, - )

pattern DefaultDecl :: forall dom. TypeList dom -> Decl dom Source #

Default types ( default (T1, T2) )

pattern TypeSigDecl :: forall dom. TypeSignature dom -> Decl dom Source #

Type signature declaration ( f :: Int -> Int )

pattern ValueBinding :: forall dom. ValueBind dom -> Decl dom Source #

Function or value binding ( f x = 12 )

pattern SpliceDecl :: forall dom. Splice dom -> Decl dom Source #

A Template Haskell splice declaration ( $(generateDecls) )

Data type definitions

pattern DataDecl :: forall dom. DataOrNewtypeKeyword dom -> MaybeContext dom -> DeclHead dom -> ConDeclList dom -> MaybeDeriving dom -> Decl dom Source #

A data or newtype declaration. Empty data type declarations without where keyword are always belong to DataDecl.

pattern GADTDataDecl :: forall dom. () => forall dome stage. DataOrNewtypeKeyword dom -> MaybeContext dom -> DeclHead dom -> MaybeKindConstraint dome -> AnnListG UGadtConDecl dom stage -> MaybeDeriving dom -> Decl dom Source #

A GADT-style data or newtype declaration.

pattern GadtConDecl :: forall dom. NameList dom -> Type dom -> GadtConDecl dom Source #

GADT constructor declaration ( D1 :: Int -> T String )

pattern GadtRecordConDecl :: forall dom. NameList dom -> FieldDeclList dom -> Type dom -> GadtConDecl dom Source #

GADT constructor declaration with record syntax ( D1 :: { val :: Int } -> T String )

pattern ConDecl :: forall dom. Name dom -> TypeList dom -> ConDecl dom Source #

Ordinary data constructor ( C t1 t2 )

pattern RecordConDecl :: forall dom. Name dom -> FieldDeclList dom -> ConDecl dom Source #

Creates a record data constructor ( Point { x :: Double, y :: Double } )

pattern InfixConDecl :: forall dom. Type dom -> Operator dom -> Type dom -> ConDecl dom Source #

Infix data constructor ( t1 :+: t2 )

pattern FieldDecl :: forall dom. NameList dom -> Type dom -> FieldDecl dom Source #

Field declaration ( fld :: Int )

pattern DerivingOne :: forall dom. InstanceHead dom -> Deriving dom Source #

A deriving clause without parentheses ( deriving Show .

pattern DerivingMulti :: forall dom. InstanceHeadList dom -> Deriving dom Source #

A deriving clause with parentheses deriving (Show, Eq) )

pattern DataKeyword :: forall dom. DataOrNewtypeKeyword dom Source #

pattern NewtypeKeyword :: forall dom. DataOrNewtypeKeyword dom Source #

pattern FunDeps :: forall dom. FunDepList dom -> FunDeps dom Source #

A list of functional dependencies: | a -> b, c -> d separated by commas

pattern FunDep :: forall dom. NameList dom -> NameList dom -> FunDep dom Source #

A functional dependency, given on the form l1 ... ln -> r1 ... rn

Type class declarations

pattern ClassDecl :: forall dom. MaybeContext dom -> DeclHead dom -> MaybeFunDeps dom -> MaybeClassBody dom -> Decl dom Source #

Type class declaration ( class X a [where f = ...] )

pattern ClassBody :: forall dom. ClassElementList dom -> ClassBody dom Source #

The list of declarations that can appear in a typeclass

pattern ClassElemSig :: forall dom. TypeSignature dom -> ClassElement dom Source #

Type signature: f :: A -> B as a class member

pattern ClassElemDef :: forall dom. ValueBind dom -> ClassElement dom Source #

Default binding: f x = "aaa" as a class member

pattern ClassElemTypeFam :: forall dom. DeclHead dom -> MaybeTypeFamilySpec dom -> ClassElement dom Source #

Declaration of an associated type synonym: type T x :: * in a class

pattern ClassElemDataFam :: forall dom. () => forall dome. DeclHead dom -> MaybeKindConstraint dome -> ClassElement dom Source #

Declaration of an associated data synonym: data T x :: * in a class

pattern ClsDefaultType :: forall dom. DeclHead dom -> Type dom -> ClassElement dom Source #

Default choice for type synonym: type T x = TE or type instance T x = TE in a class

pattern ClsDefaultSig :: forall dom. Name dom -> Type dom -> ClassElement dom Source #

Default signature (by using DefaultSignatures): default enum :: (Generic a, GEnum (Rep a)) => [a]

pattern ClsMinimal :: forall dom. MinimalFormula dom -> ClassElement dom Source #

Minimal pragma: {-# MINIMAL (==) | (/=) #-} in a class

pattern MinimalName :: forall dom. Name dom -> MinimalFormula dom Source #

pattern MinimalParen :: forall dom. MinimalFormula dom -> MinimalFormula dom Source #

pattern MinimalOr :: forall dom. MinimalFormulaList dom -> MinimalFormula dom Source #

One of the minimal formulas are needed ( min1 | min2 )

pattern MinimalAnd :: forall dom. MinimalFormulaList dom -> MinimalFormula dom Source #

Both of the minimal formulas are needed ( min1 , min2 )

Declaration heads

pattern NameDeclHead :: forall dom. Name dom -> DeclHead dom Source #

Type or class name as a declaration head

pattern ParenDeclHead :: forall dom. DeclHead dom -> DeclHead dom Source #

Parenthesized type as a declaration head

pattern DeclHeadApp :: forall dom. DeclHead dom -> TyVar dom -> DeclHead dom Source #

Type application as a declaration head

pattern InfixDeclHead :: forall dom. TyVar dom -> Operator dom -> TyVar dom -> DeclHead dom Source #

Infix type application as a declaration head

Type class instance declarations

pattern InstanceDecl :: forall dom. InstanceRule dom -> MaybeInstBody dom -> Decl dom Source #

Instance declaration ( instance X T [where f = ...] )

pattern InstanceBody :: forall dom. InstBodyDeclList dom -> InstBody dom Source #

Instance body is the implementation of the class functions ( where a x = 1; b x = 2 )

pattern InstanceBind :: forall dom. ValueBind dom -> InstBodyDecl dom Source #

A normal value binding ( f x = 12 ) inside a class instance

pattern InstanceTypeSig :: forall dom. TypeSignature dom -> InstBodyDecl dom Source #

Type signature in instance definition with InstanceSigs

pattern InstanceTypeFamilyDef :: forall dom. TypeEqn dom -> InstBodyDecl dom Source #

An associated type definition ( type A X = B ) in a class instance

pattern InstanceDataFamilyDef :: forall dom. DataOrNewtypeKeyword dom -> InstanceRule dom -> ConDeclList dom -> MaybeDeriving dom -> InstBodyDecl dom Source #

An associated data definition ( data A X = B Int | C ) in a class instance

pattern InstanceDataFamilyGADTDef :: forall dom. () => forall dome stage. DataOrNewtypeKeyword dom -> InstanceRule dom -> MaybeKindConstraint dome -> AnnListG UGadtConDecl dom stage -> MaybeDeriving dom -> InstBodyDecl dom Source #

An associated data definition as a GADT ( data A X where B :: Int -> A X ) in a class instance

pattern InstanceSpecializePragma :: forall dom. Type dom -> InstBodyDecl dom Source #

Specialize instance pragma in a class instance (no phase selection is allowed)

pattern InstanceRule :: forall dom. () => forall stage. AnnMaybeG (AnnListG UTyVar) dom stage -> MaybeContext dom -> InstanceHead dom -> InstanceRule dom Source #

Instance head as an instance rule ( X a => Y a )

pattern InstanceHead :: forall dom. Name dom -> InstanceHead dom Source #

Type or class name as an instance head

pattern InfixInstanceHead :: forall dom. Type dom -> Name dom -> InstanceHead dom Source #

Infix application of the type/class name to the left operand as an instance head

pattern ParenInstanceHead :: forall dom. InstanceHead dom -> InstanceHead dom Source #

Parenthesized instance head

pattern AppInstanceHead :: forall dom. InstanceHead dom -> Type dom -> InstanceHead dom Source #

Type application as an instance head

pattern EnableOverlap :: forall dom. OverlapPragma dom Source #

OVERLAP pragma

pattern DisableOverlap :: forall dom. OverlapPragma dom Source #

NO_OVERLAP pragma

pattern Overlappable :: forall dom. OverlapPragma dom Source #

OVERLAPPABLE pragma

pattern Overlapping :: forall dom. OverlapPragma dom Source #

OVERLAPPING pragma

pattern Overlaps :: forall dom. OverlapPragma dom Source #

OVERLAPS pragma

pattern IncoherentOverlap :: forall dom. OverlapPragma dom Source #

INCOHERENT pragma

Type roles

pattern RoleDecl :: forall dom. QualifiedName dom -> RoleList dom -> Decl dom Source #

Role annotations ( type role Ptr representational )

pattern NominalRole :: forall dom. Role dom Source #

pattern RepresentationalRole :: forall dom. Role dom Source #

pattern PhantomRole :: forall dom. Role dom Source #

Foreign imports and exports

pattern ForeignImport :: forall dom. CallConv dom -> MaybeSafety dom -> Name dom -> Type dom -> Decl dom Source #

Foreign import ( foreign import foo :: Int -> IO Int )

pattern ForeignExport :: forall dom. CallConv dom -> Name dom -> Type dom -> Decl dom Source #

Foreign export ( foreign export ccall foo :: Int -> IO Int )

pattern StdCall :: forall dom. CallConv dom Source #

Specifies stdcall calling convention for foreign import/export.

pattern CCall :: forall dom. CallConv dom Source #

Specifies ccall calling convention for foreign import/export.

pattern CApi :: forall dom. CallConv dom Source #

Specifies capi calling convention for foreign import/export.

pattern Unsafe :: forall dom. Safety dom Source #

Specifies that the given foreign import is unsafe.

Pattern synonyms

pattern PatternSynonym :: forall dom. PatSynLhs dom -> PatSynRhs dom -> Decl dom Source #

Pattern synonyms ( pattern Arrow t1 t2 = App "->" [t1, t2] )

pattern ConPatSyn :: forall dom. Name dom -> NameList dom -> PatSynLhs dom Source #

A left hand side with a constructor name and arguments ( Arrow t1 t2 )

pattern InfixPatSyn :: forall dom. Name dom -> Operator dom -> Name dom -> PatSynLhs dom Source #

An infix pattern synonym left-hand side ( t1 :+: t2 )

pattern RecordPatSyn :: forall dom. Name dom -> NameList dom -> PatSynLhs dom Source #

A record-style pattern synonym left-hand side ( Arrow { arrowFrom, arrowTo } )

pattern SymmetricPatSyn :: forall dom. Pattern dom -> PatSynRhs dom Source #

An automatically two-way pattern synonym ( = App "Int" [] )

pattern OneWayPatSyn :: forall dom. Pattern dom -> PatSynRhs dom Source #

A pattern synonym that can be only used for pattenr matching but not for combining ( <- App "Int" [] )

pattern TwoWayPatSyn :: forall dom. Pattern dom -> MatchList dom -> PatSynRhs dom Source #

A pattern synonym with the other direction explicitely specified ( <- App "Int" [] where Int = App "Int" [] )

pattern PatternSignatureDecl :: forall dom. PatternSignature dom -> Decl dom Source #

Pattern type signature declaration ( pattern Succ :: Int -> Int )

pattern PatternSignature :: forall dom. Name dom -> Type dom -> PatternSignature dom Source #

Type families

pattern TypeFamily :: forall dom. DeclHead dom -> MaybeTypeFamilySpec dom -> Decl dom Source #

Type family declaration ( type family A a :: * -> * )

pattern DataFamily :: forall dom. DeclHead dom -> MaybeKindConstraint dom -> Decl dom Source #

Data family declaration ( data family A a :: * -> * )

pattern TypeInstance :: forall dom. InstanceRule dom -> Type dom -> Decl dom Source #

Type family instance declaration ( type instance Fam T = AssignedT )

pattern DataInstance :: forall dom. DataOrNewtypeKeyword dom -> InstanceRule dom -> ConDeclList dom -> MaybeDeriving dom -> Decl dom Source #

Data instance declaration ( data instance Fam T = Con1 | Con2 )

pattern GadtDataInstance :: forall dom. () => forall dome. DataOrNewtypeKeyword dom -> InstanceRule dom -> MaybeKindConstraint dome -> GadtConDeclList dom -> Decl dom Source #

GADT-style data instance declaration ( data instance Fam T where ... )

pattern ClosedTypeFamily :: forall dom. DeclHead dom -> MaybeKindConstraint dom -> TypeEqnList dom -> Decl dom Source #

A closed type family declaration

pattern TypeFamilyKindSpec :: forall dom. KindConstraint dom -> TypeFamilySpec dom Source #

Specifies the kind of a type family ( :: * -> * )

pattern TypeFamilyInjectivitySpec :: forall dom. Name dom -> NameList dom -> TypeFamilySpec dom Source #

Specifies the injectivity of a type family ( = r | r -> a )

pattern TypeEqn :: forall dom. Type dom -> Type dom -> TypeEqn dom Source #

Type equations as found in closed type families ( T A = S )

Top level pragmas

pattern PragmaDecl :: forall dom. TopLevelPragma dom -> Decl dom Source #

Top-level pragmas

pattern RulePragma :: forall dom. RuleList dom -> TopLevelPragma dom Source #

A pragma that introduces source rewrite rules ( {-# RULES "map/map" [2] forall f g xs. map f (map g xs) = map (f.g) xs #-} )

pattern DeprPragma :: forall dom. NameList dom -> String -> TopLevelPragma dom Source #

A pragma that marks definitions as deprecated ( {-# DEPRECATED f "f will be replaced by g" #-} )

pattern WarningPragma :: forall dom. NameList dom -> String -> TopLevelPragma dom Source #

A pragma that marks definitions as deprecated ( {-# WARNING unsafePerformIO "you should know what you are doing" #-} )

pattern AnnPragma :: forall dom. AnnotationSubject dom -> Expr dom -> TopLevelPragma dom Source #

A pragma that annotates a definition with an arbitrary value ( {-# ANN f 42 #-} )

pattern InlinePragma :: forall dom. MaybeConlikeAnnot dom -> MaybePhaseControl dom -> Name dom -> TopLevelPragma dom Source #

A pragma that marks a function for inlining to the compiler ( {-# INLINE thenUs #-} )

pattern NoInlinePragma :: forall dom. Name dom -> TopLevelPragma dom Source #

A pragma that forbids a function from being inlined by the compiler ( {-# NOINLINE f #-} )

pattern InlinablePragma :: forall dom. MaybePhaseControl dom -> Name dom -> TopLevelPragma dom Source #

A pragma that marks a function that it may be inlined by the compiler ( {-# INLINABLE thenUs #-} )

pattern LinePragma :: forall dom. Int -> MaybeStringNode dom -> TopLevelPragma dom Source #

A pragma for maintaining line numbers in generated sources ( {-# LINE 123 "somefile" #-} )

pattern SpecializePragma :: forall dom. MaybePhaseControl dom -> Name dom -> TypeList dom -> TopLevelPragma dom Source #

A pragma that tells the compiler that a polymorph function should be optimized for a given type ( {-# SPECIALISE f :: Int -> b -> b #-} )

pattern PhaseControlFrom :: forall dom. Integer -> PhaseControl dom Source #

Marks that the pragma should be applied from a given compile phase ( [2] )

pattern PhaseControlUntil :: forall dom. Integer -> PhaseControl dom Source #

Marks that the pragma should be applied until a given compile phase ( [~2] )

pattern RewriteRule :: forall dom. String -> MaybePhaseControl dom -> TyVarList dom -> Expr dom -> Expr dom -> Rule dom Source #

A rewrite rule ( "map/map" forall f g xs. map f (map g xs) = map (f.g) xs )

pattern NameAnnotation :: forall dom. Name dom -> AnnotationSubject dom Source #

The definition with the given name is annotated

pattern TypeAnnotation :: forall dom. Name dom -> AnnotationSubject dom Source #

A type with the given name is annotated

pattern ModuleAnnotation :: forall dom. AnnotationSubject dom Source #

The whole module is annotated

pattern ConlikeAnnotation :: forall dom. ConlikeAnnot dom Source #

A CONLIKE modifier for an INLINE pragma.