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

Safe HaskellNone
LanguageHaskell2010

Language.Haskell.Tools.Rewrite.Match.Decls

Contents

Description

UPattern matching on declaration-level AST fragments for refactorings.

Synopsis

Declarations

pattern TypeDecl :: DeclHead -> Type -> Decl Source #

A type synonym ( type String = [Char] )

pattern StandaloneDeriving :: Maybe DeriveStrategy -> Maybe OverlapPragma -> InstanceRule -> Decl Source #

Standalone deriving declaration ( deriving instance X T )

pattern FixityDecl :: FixitySignature -> Decl Source #

Fixity declaration ( infixl 5 +, - )

pattern DefaultDecl :: TypeList -> Decl Source #

Default types ( default (T1, T2) )

pattern TypeSigDecl :: TypeSignature -> Decl Source #

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

pattern ValueBinding :: ValueBind -> Decl Source #

Function or value binding ( f x = 12 )

pattern SpliceDecl :: Splice -> Decl Source #

A Template Haskell splice declaration ( $(generateDecls) )

Data type definitions

pattern DataDecl :: DataOrNewtypeKeyword -> MaybeContext -> DeclHead -> ConDeclList -> DerivingList -> Decl Source #

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

pattern GADTDataDecl :: DataOrNewtypeKeyword -> MaybeContext -> DeclHead -> MaybeKindConstraint -> AnnList UGadtConDecl -> DerivingList -> Decl Source #

A GADT-style data or newtype declaration.

pattern GadtConDecl :: NameList -> Type -> GadtConDecl Source #

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

pattern GadtRecordConDecl :: NameList -> FieldDeclList -> Type -> GadtConDecl Source #

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

pattern ConDecl :: Name -> TypeList -> ConDecl Source #

Ordinary data constructor ( C t1 t2 )

pattern RecordConDecl :: Name -> FieldDeclList -> ConDecl Source #

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

pattern InfixConDecl :: Type -> Operator -> Type -> ConDecl Source #

Infix data constructor ( t1 :+: t2 )

pattern FieldDecl :: NameList -> Type -> FieldDecl Source #

Field declaration ( fld :: Int )

pattern DerivingOne :: InstanceHead -> Deriving Source #

A deriving clause without parentheses ( deriving Show .

pattern DerivingOne' :: MaybeDeriveStrategy -> InstanceHead -> Deriving Source #

A deriving clause without parentheses, with/witohut strategy ( deriving stock Show .

pattern DerivingMulti :: InstanceHeadList -> Deriving Source #

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

pattern DerivingMulti' :: MaybeDeriveStrategy -> InstanceHeadList -> Deriving Source #

A deriving clause with parentheses, with/witohut strategy ( deriving stock (Show, Eq) .

pattern FunDeps :: FunDepList -> FunDeps Source #

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

pattern FunDep :: NameList -> NameList -> FunDep Source #

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

Type class declarations

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

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

pattern ClassBody :: ClassElementList -> ClassBody Source #

The list of declarations that can appear in a typeclass

pattern ClassElemSig :: TypeSignature -> ClassElement Source #

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

pattern ClassElemDef :: ValueBind -> ClassElement Source #

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

pattern ClassElemTypeFam :: DeclHead -> MaybeTypeFamilySpec -> ClassElement Source #

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

pattern ClassElemDataFam :: DeclHead -> MaybeKindConstraint -> ClassElement Source #

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

pattern ClsDefaultType :: DeclHead -> Type -> ClassElement Source #

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

pattern ClsDefaultSig :: Name -> Type -> ClassElement Source #

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

pattern ClsMinimal :: MinimalFormula -> ClassElement Source #

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

pattern MinimalOr :: MinimalFormulaList -> MinimalFormula Source #

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

pattern MinimalAnd :: MinimalFormulaList -> MinimalFormula Source #

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

Declaration heads

pattern NameDeclHead :: Name -> DeclHead Source #

Type or class name as a declaration head

pattern ParenDeclHead :: DeclHead -> DeclHead Source #

Parenthesized type as a declaration head

pattern DeclHeadApp :: DeclHead -> TyVar -> DeclHead Source #

Type application as a declaration head

pattern InfixDeclHead :: TyVar -> Operator -> TyVar -> DeclHead Source #

Infix type application as a declaration head

Type class instance declarations

pattern InstanceDecl :: InstanceRule -> MaybeInstBody -> Decl Source #

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

pattern InstanceBody :: InstBodyDeclList -> InstBody Source #

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

pattern InstanceBind :: ValueBind -> InstBodyDecl Source #

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

pattern InstanceTypeSig :: TypeSignature -> InstBodyDecl Source #

Type signature in instance definition with InstanceSigs

pattern InstanceTypeFamilyDef :: TypeEqn -> InstBodyDecl Source #

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

pattern InstanceDataFamilyDef :: DataOrNewtypeKeyword -> InstanceRule -> ConDeclList -> DerivingList -> InstBodyDecl Source #

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

pattern InstanceDataFamilyGADTDef :: DataOrNewtypeKeyword -> InstanceRule -> MaybeKindConstraint -> AnnList UGadtConDecl -> DerivingList -> InstBodyDecl Source #

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

pattern InstanceSpecializePragma :: Type -> InstBodyDecl Source #

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

pattern InstanceRule :: AnnMaybe (AnnListG UTyVar) -> MaybeContext -> InstanceHead -> InstanceRule Source #

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

pattern InstanceHead :: Name -> InstanceHead Source #

Type or class name as an instance head

pattern InfixInstanceHead :: Type -> Operator -> InstanceHead Source #

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

pattern ParenInstanceHead :: InstanceHead -> InstanceHead Source #

Parenthesized instance head

pattern AppInstanceHead :: InstanceHead -> Type -> InstanceHead Source #

Type application as an instance head

pattern EnableOverlap :: OverlapPragma Source #

OVERLAP pragma

pattern DisableOverlap :: OverlapPragma Source #

NO_OVERLAP pragma

pattern Overlappable :: OverlapPragma Source #

OVERLAPPABLE pragma

pattern Overlapping :: OverlapPragma Source #

OVERLAPPING pragma

pattern Overlaps :: OverlapPragma Source #

OVERLAPS pragma

pattern IncoherentOverlap :: OverlapPragma Source #

INCOHERENT pragma

Type roles

pattern RoleDecl :: QualifiedName -> RoleList -> Decl Source #

Role annotations ( type role Ptr representational )

Foreign imports and exports

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

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

pattern ForeignExport :: CallConv -> Name -> Type -> Decl Source #

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

pattern StdCall :: CallConv Source #

Specifies stdcall calling convention for foreign import/export.

pattern CCall :: CallConv Source #

Specifies ccall calling convention for foreign import/export.

pattern CApi :: CallConv Source #

Specifies capi calling convention for foreign import/export.

pattern Unsafe :: Safety Source #

Specifies that the given foreign import is unsafe.

Pattern synonyms

pattern PatternSynonym :: PatSynLhs -> PatSynRhs -> Decl Source #

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

pattern ConPatSyn :: Name -> NameList -> PatSynLhs Source #

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

pattern InfixPatSyn :: Name -> Operator -> Name -> PatSynLhs Source #

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

pattern RecordPatSyn :: Name -> NameList -> PatSynLhs Source #

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

pattern SymmetricPatSyn :: Pattern -> PatSynRhs Source #

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

pattern OneWayPatSyn :: Pattern -> PatSynRhs Source #

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

pattern TwoWayPatSyn :: Pattern -> MatchList -> PatSynRhs Source #

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

pattern PatternSignatureDecl :: PatternSignature -> Decl Source #

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

Type families

pattern TypeFamily :: DeclHead -> MaybeTypeFamilySpec -> Decl Source #

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

pattern DataFamily :: DeclHead -> MaybeKindConstraint -> Decl Source #

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

pattern TypeInstance :: InstanceRule -> Type -> Decl Source #

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

pattern DataInstance :: DataOrNewtypeKeyword -> InstanceRule -> ConDeclList -> DerivingList -> Decl Source #

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

pattern GadtDataInstance :: DataOrNewtypeKeyword -> InstanceRule -> MaybeKindConstraint -> GadtConDeclList -> Decl Source #

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

pattern ClosedTypeFamily :: DeclHead -> MaybeTypeFamilySpec -> TypeEqnList -> Decl Source #

A closed type family declaration

pattern TypeFamilyKindSpec :: KindConstraint -> TypeFamilySpec Source #

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

pattern TypeFamilyInjectivitySpec :: TyVar -> NameList -> TypeFamilySpec Source #

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

pattern TypeEqn :: Type -> Type -> TypeEqn Source #

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

Top level pragmas

pattern PragmaDecl :: TopLevelPragma -> Decl Source #

Top-level pragmas

pattern RulePragma :: RuleList -> TopLevelPragma 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 :: NameList -> String -> TopLevelPragma Source #

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

pattern WarningPragma :: NameList -> String -> TopLevelPragma Source #

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

pattern AnnPragma :: AnnotationSubject -> Expr -> TopLevelPragma Source #

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

pattern InlinePragma :: MaybeConlikeAnnot -> MaybePhaseControl -> Name -> TopLevelPragma Source #

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

pattern NoInlinePragma :: Name -> TopLevelPragma Source #

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

pattern InlinablePragma :: MaybePhaseControl -> Name -> TopLevelPragma Source #

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

pattern LinePragma :: Int -> MaybeStringNode -> TopLevelPragma Source #

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

pattern SpecializePragma :: MaybePhaseControl -> Name -> TypeList -> TopLevelPragma 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 :: Integer -> PhaseControl Source #

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

pattern PhaseControlUntil :: Integer -> PhaseControl Source #

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

pattern RewriteRule :: String -> MaybePhaseControl -> RuleVarList -> Expr -> Expr -> Rule Source #

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

pattern NameAnnotation :: Name -> AnnotationSubject Source #

The definition with the given name is annotated

pattern TypeAnnotation :: Name -> AnnotationSubject Source #

A type with the given name is annotated

pattern ModuleAnnotation :: AnnotationSubject Source #

The whole module is annotated

pattern ConlikeAnnotation :: ConlikeAnnot Source #

A CONLIKE modifier for an INLINE pragma.