haskell-tools-rewrite-1.1.0.1: 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 #

A type synonym ( type String = [Char] )

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

Standalone deriving declaration ( deriving instance X T )

pattern FixityDecl :: FixitySignature -> Decl #

Fixity declaration ( infixl 5 +, - )

pattern DefaultDecl :: TypeList -> Decl #

Default types ( default (T1, T2) )

pattern TypeSigDecl :: TypeSignature -> Decl #

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

pattern ValueBinding :: ValueBind -> Decl #

Function or value binding ( f x = 12 )

pattern SpliceDecl :: Splice -> Decl #

A Template Haskell splice declaration ( $(generateDecls) )

Data type definitions

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

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 #

A GADT-style data or newtype declaration.

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

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

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

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

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

Ordinary data constructor ( C t1 t2 )

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

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

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

Infix data constructor ( t1 :+: t2 )

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

Field declaration ( fld :: Int )

pattern DerivingOne :: InstanceHead -> Deriving #

A deriving clause without parentheses ( deriving Show .

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

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

pattern DerivingMulti :: InstanceHeadList -> Deriving #

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

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

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

pattern FunDeps :: FunDepList -> FunDeps #

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

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

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

Type class declarations

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

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

pattern ClassBody :: ClassElementList -> ClassBody #

The list of declarations that can appear in a typeclass

pattern ClassElemSig :: TypeSignature -> ClassElement #

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

pattern ClassElemDef :: ValueBind -> ClassElement #

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

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

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

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

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

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

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

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

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

pattern ClsMinimal :: MinimalFormula -> ClassElement #

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

pattern MinimalOr :: MinimalFormulaList -> MinimalFormula #

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

pattern MinimalAnd :: MinimalFormulaList -> MinimalFormula #

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

Declaration heads

pattern NameDeclHead :: Name -> DeclHead #

Type or class name as a declaration head

pattern ParenDeclHead :: DeclHead -> DeclHead #

Parenthesized type as a declaration head

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

Type application as a declaration head

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

Infix type application as a declaration head

Type class instance declarations

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

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

pattern InstanceBody :: InstBodyDeclList -> InstBody #

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

pattern InstanceBind :: ValueBind -> InstBodyDecl #

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

pattern InstanceTypeSig :: TypeSignature -> InstBodyDecl #

Type signature in instance definition with InstanceSigs

pattern InstanceTypeFamilyDef :: TypeEqn -> InstBodyDecl #

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

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

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

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

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

pattern InstanceSpecializePragma :: Type -> InstBodyDecl #

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

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

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

pattern InstanceHead :: Name -> InstanceHead #

Type or class name as an instance head

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

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

pattern ParenInstanceHead :: InstanceHead -> InstanceHead #

Parenthesized instance head

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

Type application as an instance head

pattern EnableOverlap :: OverlapPragma #

OVERLAP pragma

pattern DisableOverlap :: OverlapPragma #

NO_OVERLAP pragma

pattern Overlappable :: OverlapPragma #

OVERLAPPABLE pragma

pattern Overlapping :: OverlapPragma #

OVERLAPPING pragma

pattern Overlaps :: OverlapPragma #

OVERLAPS pragma

pattern IncoherentOverlap :: OverlapPragma #

INCOHERENT pragma

Type roles

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

Role annotations ( type role Ptr representational )

pattern NominalRole :: Role #

pattern PhantomRole :: Role #

Foreign imports and exports

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

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

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

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

pattern StdCall :: CallConv #

Specifies stdcall calling convention for foreign import/export.

pattern CCall :: CallConv #

Specifies ccall calling convention for foreign import/export.

pattern CApi :: CallConv #

Specifies capi calling convention for foreign import/export.

pattern Unsafe :: Safety #

Specifies that the given foreign import is unsafe.

Pattern synonyms

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

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

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

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

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

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

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

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

pattern SymmetricPatSyn :: Pattern -> PatSynRhs #

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

pattern OneWayPatSyn :: Pattern -> PatSynRhs #

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

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

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

pattern PatternSignatureDecl :: PatternSignature -> Decl #

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

Type families

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

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

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

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

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

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

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

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

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

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

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

A closed type family declaration

pattern TypeFamilyKindSpec :: KindConstraint -> TypeFamilySpec #

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

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

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

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

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

Top level pragmas

pattern PragmaDecl :: TopLevelPragma -> Decl #

Top-level pragmas

pattern RulePragma :: RuleList -> TopLevelPragma #

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 #

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

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

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

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

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

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

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

pattern NoInlinePragma :: Name -> TopLevelPragma #

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

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

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

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

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

pattern SpecializePragma :: MaybePhaseControl -> Name -> TypeList -> TopLevelPragma #

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 #

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

pattern PhaseControlUntil :: Integer -> PhaseControl #

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

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

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

pattern NameAnnotation :: Name -> AnnotationSubject #

The definition with the given name is annotated

pattern TypeAnnotation :: Name -> AnnotationSubject #

A type with the given name is annotated

pattern ModuleAnnotation :: AnnotationSubject #

The whole module is annotated

pattern ConlikeAnnotation :: ConlikeAnnot #

A CONLIKE modifier for an INLINE pragma.