Safe Haskell | None |
---|---|
Language | Haskell2010 |
Generation of expression-level AST fragments for refactorings.
The bindings defined here create a the annotated version of the AST constructor with the same name.
For example, mkApp
creates the annotated version of the App
AST constructor.
- mkVar :: Name -> Expr
- mkLit :: Literal -> Expr
- mkInfixApp :: Expr -> Operator -> Expr -> Expr
- mkPrefixApp :: Operator -> Expr -> Expr
- mkApp :: Expr -> Expr -> Expr
- mkLambda :: [Pattern] -> Expr -> Expr
- mkLet :: [LocalBind] -> Expr -> Expr
- mkIf :: Expr -> Expr -> Expr -> Expr
- mkMultiIf :: [GuardedCaseRhs] -> Expr
- mkCase :: Expr -> [Alt] -> Expr
- mkDoBlock :: [Stmt] -> Expr
- mkTuple :: [Expr] -> Expr
- mkUnboxedTuple :: [Expr] -> Expr
- mkTupleSection :: [Maybe Expr] -> Expr
- mkTupleUnboxedSection :: [Maybe Expr] -> Expr
- mkList :: [Expr] -> Expr
- mkParArray :: [Expr] -> Expr
- mkParen :: Expr -> Expr
- mkLeftSection :: Expr -> Operator -> Expr
- mkRightSection :: Operator -> Expr -> Expr
- mkRecCon :: Name -> [FieldUpdate] -> Expr
- mkRecUpdate :: Expr -> [FieldUpdate] -> Expr
- mkEnum :: Expr -> Maybe Expr -> Maybe Expr -> Expr
- mkParArrayEnum :: Expr -> Maybe Expr -> Expr -> Expr
- mkListComp :: Expr -> [ListCompBody] -> Expr
- mkParArrayComp :: Expr -> [ListCompBody] -> Expr
- mkExprTypeSig :: Expr -> Type -> Expr
- mkExplicitTypeApp :: Expr -> Type -> Expr
- mkVarQuote :: Name -> Expr
- mkTypeQuote :: Name -> Expr
- mkBracketExpr :: Bracket -> Expr
- mkSpliceExpr :: Splice -> Expr
- mkQuasiQuoteExpr :: QuasiQuote -> Expr
- mkExprPragma :: ExprPragma -> Expr -> Expr
- mkProcExpr :: Pattern -> Cmd -> Expr
- mkArrowApp :: Expr -> ArrowApp -> Expr -> Expr
- mkLambdaCase :: [Alt] -> Expr
- mkStaticPointer :: Expr -> Expr
- mkFieldUpdate :: Name -> Expr -> FieldUpdate
- mkFieldPun :: Name -> FieldUpdate
- mkFieldWildcard :: FieldUpdate
- mkAlt :: Pattern -> CaseRhs -> Maybe LocalBinds -> Alt
- mkCaseRhs :: Expr -> CaseRhs
- mkGuardedCaseRhss :: [GuardedCaseRhs] -> CaseRhs
- mkGuardedCaseRhs :: [RhsGuard] -> Expr -> GuardedCaseRhs
- mkCorePragma :: String -> ExprPragma
- mkSccPragma :: String -> ExprPragma
- mkGeneratedPragma :: SourceRange -> ExprPragma
- mkSourceRange :: String -> Integer -> Integer -> Integer -> Integer -> SourceRange
- mkArrowAppCmd :: Expr -> ArrowApp -> Expr -> Cmd
- mkArrowFromCmd :: Expr -> [Cmd] -> Cmd
- mkAppCmd :: Cmd -> Expr -> Cmd
- mkInfixCmd :: Cmd -> Name -> Cmd -> Cmd
- mkLambdaCmd :: [Pattern] -> Cmd -> Cmd
- mkParenCmd :: Cmd -> Cmd
- mkCaseCmd :: Expr -> [CmdAlt] -> Cmd
- mkIfCmd :: Expr -> Cmd -> Cmd -> Cmd
- mkLetCmd :: [LocalBind] -> Cmd -> Cmd
- mkDoCmd :: [CmdStmt] -> Cmd
- mkLeftAppl :: ArrowApp
- mkRightAppl :: ArrowApp
- mkLeftHighAppl :: ArrowApp
- mkRightHighAppl :: ArrowApp
- mkHole :: Expr
Expressions
mkInfixApp :: Expr -> Operator -> Expr -> Expr Source #
Create a infix operator application expression ( a + b
)
mkPrefixApp :: Operator -> Expr -> Expr Source #
Create a prefix operator application expression ( -x
)
mkMultiIf :: [GuardedCaseRhs] -> Expr Source #
Create a multi way if expressions with MultiWayIf
extension ( if | guard1 -> expr1; guard2 -> expr2
)
mkCase :: Expr -> [Alt] -> Expr Source #
Create a pattern matching expression ( case expr of pat1 -> expr1; pat2 -> expr2
)
mkUnboxedTuple :: [Expr] -> Expr Source #
Create a unboxed tuple expression ( (# e1, e2, e3 #)
)
mkTupleSection :: [Maybe Expr] -> Expr Source #
Create a tuple section, enabled with TupleSections
( (a,,b)
). One of the elements must be missing.
mkTupleUnboxedSection :: [Maybe Expr] -> Expr Source #
Create a unboxed tuple section, enabled with TupleSections
( (#a,,b#)
). One of the elements must be missing.
mkParArray :: [Expr] -> Expr Source #
Create a parallel array expression: [: 1,2,3 :]
mkRecCon :: Name -> [FieldUpdate] -> Expr Source #
Create a record value construction: Point { x = 3, y = -2 }
mkRecUpdate :: Expr -> [FieldUpdate] -> Expr Source #
Create a record value update: p1 { x = 3, y = -2 }
mkEnum :: Expr -> Maybe Expr -> Maybe Expr -> Expr Source #
Create a enumeration expression ( [1,3..10]
)
mkParArrayEnum :: Expr -> Maybe Expr -> Expr -> Expr Source #
Create a parallel array enumeration ( [: 1,3 .. 10 :]
)
mkListComp :: Expr -> [ListCompBody] -> Expr Source #
Create a list comprehension ( [ (x, y) | x <- xs | y <- ys ]
)
mkParArrayComp :: Expr -> [ListCompBody] -> Expr Source #
Create a parallel array comprehensions [: (x, y) | x <- xs , y <- ys :]
enabled by ParallelArrays
mkExplicitTypeApp :: Expr -> Type -> Expr Source #
Create a explicit type application ( show @Integer (read "5")
)
mkVarQuote :: Name -> Expr Source #
'x
for template haskell reifying of expressions
mkTypeQuote :: Name -> Expr Source #
''T
for template haskell reifying of types
mkBracketExpr :: Bracket -> Expr Source #
Create a template haskell bracket expression
mkSpliceExpr :: Splice -> Expr Source #
Create a template haskell splice expression, for example: $(gen a)
or $x
mkQuasiQuoteExpr :: QuasiQuote -> Expr Source #
Create a template haskell quasi quote expression, for example: [quoter| a + b ]
mkExprPragma :: ExprPragma -> Expr -> Expr Source #
Creates a pragma that marks an expression.
mkArrowApp :: Expr -> ArrowApp -> Expr -> Expr Source #
Create a arrow definition: proc a -> f -< a+1
mkLambdaCase :: [Alt] -> Expr Source #
Create a lambda case ( case 0 -> 1; 1 -> 2
)
mkStaticPointer :: Expr -> Expr Source #
Create a static pointer expression ( static e
). The inner expression must be closed (cannot have variables bound outside)
Field updates
mkFieldUpdate :: Name -> Expr -> FieldUpdate Source #
Create a update of a field ( x = 1
)
mkFieldPun :: Name -> FieldUpdate Source #
Create a update the field to the value of the same name ( x
)
mkFieldWildcard :: FieldUpdate Source #
Create a update the fields of the bounded names to their values ( ..
). Must be the last initializer. Cannot be used in a record update expression.
Pattern matching and guards
mkAlt :: Pattern -> CaseRhs -> Maybe LocalBinds -> Alt Source #
Create a clause of case expression ( Just x -> x + 1
)
mkGuardedCaseRhss :: [GuardedCaseRhs] -> CaseRhs Source #
Create a guarded right-hand sides of a pattern match ( | x == 1 -> 3; | otherwise -> 4
)
mkGuardedCaseRhs :: [RhsGuard] -> Expr -> GuardedCaseRhs Source #
Creates a guarded right-hand side of pattern matches binding ( | x > 3 -> 2
)
Pragmas that can be applied to expressions
mkCorePragma :: String -> ExprPragma Source #
Creates a CORE
pragma for adding notes to expressions.
mkSccPragma :: String -> ExprPragma Source #
Creates an SCC
pragma for defining cost centers for profiling
mkGeneratedPragma :: SourceRange -> ExprPragma Source #
Creates a pragma that describes if an expression was generated from a code fragment by an external tool ( {-# GENERATED "Happy.y" 1:15-1:25 #-}
)
mkSourceRange :: String -> Integer -> Integer -> Integer -> Integer -> SourceRange Source #
Create a in-AST source ranges (for generated pragmas)
Commands
mkArrowAppCmd :: Expr -> ArrowApp -> Expr -> Cmd Source #
An arrow application command ( f -< x + 1
)
mkArrowFromCmd :: Expr -> [Cmd] -> Cmd Source #
A form command ( (|untilA (increment -< x+y) (within 0.5 -< x)|)
)
mkParenCmd :: Cmd -> Cmd Source #
A parenthesized command
mkLeftAppl :: ArrowApp Source #
Left arrow application: -<
mkRightAppl :: ArrowApp Source #
Right arrow application: >-
mkLeftHighAppl :: ArrowApp Source #
Left arrow high application: -<<
mkRightHighAppl :: ArrowApp Source #
Right arrow high application: >>-