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

Safe HaskellNone
LanguageHaskell2010

Language.Haskell.Tools.AST.Gen.Binds

Description

Generation of binding-level AST fragments for refactorings. The bindings defined here create a the annotated version of the AST constructor with the same name. For example, mkMatch creates the annotated version of the UMatch constructor.

Synopsis

Documentation

mkSimpleBind' :: Name dom -> Expr dom -> ValueBind dom Source #

A simplified function to generate simple value bindings without local definitions, guards or complex lhs.

mkSimpleBind :: Pattern dom -> Rhs dom -> Maybe (LocalBinds dom) -> ValueBind dom Source #

Creates a value binding ( v = "12" ).

mkFunctionBind :: [Match dom] -> ValueBind dom Source #

Creates a function binding ( f 0 = 1; f x = x ). All matches must have the same name.

mkFunctionBind' :: Name dom -> [([Pattern dom], Expr dom)] -> ValueBind dom Source #

A simplified function for creating function bindings without local definitions or guards.

mkMatch :: MatchLhs dom -> Rhs dom -> Maybe (LocalBinds dom) -> Match dom Source #

Creates a clause of function binding

mkMatchLhs :: Name dom -> [Pattern dom] -> MatchLhs dom Source #

Creates a match lhs with the function name and parameter names ( f a b )

mkInfixLhs :: Pattern dom -> Operator dom -> Pattern dom -> [Pattern dom] -> MatchLhs dom Source #

Creates an infix match lhs for an operator ( a + b )

mkLocalBinds :: [LocalBind dom] -> MaybeLocalBinds dom Source #

Local bindings attached to a declaration ( where x = 42 )

mkLocalValBind :: ValueBind dom -> LocalBind dom Source #

Creates a local binding for a value

mkLocalTypeSig :: TypeSignature dom -> LocalBind dom Source #

Creates a local type signature

mkLocalFixity :: FixitySignature dom -> LocalBind dom Source #

Creates a local fixity declaration

mkTypeSignature :: Name dom -> Type dom -> TypeSignature dom Source #

Creates a type signature ( f :: Int -> Int )

mkInfixL :: Int -> Operator dom -> FixitySignature dom Source #

Creates a left-associative fixity declaration ( infixl 5 +, - ).

mkInfixR :: Int -> Operator dom -> FixitySignature dom Source #

Creates a right-associative fixity declaration ( infixr 5 +, - ).

mkInfix :: Int -> Operator dom -> FixitySignature dom Source #

Creates a non-associative fixity declaration ( infix 5 +, - ).

mkUnguardedRhs :: Expr dom -> Rhs dom Source #

Creates an unguarded right-hand-side ( = 3 )

mkGuardedRhss :: [GuardedRhs dom] -> Rhs dom Source #

Creates an unguarded right-hand-side ( | x == 1 = 3; | otherwise = 4 )

mkGuardedRhs :: [RhsGuard dom] -> Expr dom -> GuardedRhs dom Source #

Creates a guarded right-hand side of a value binding ( | x > 3 = 2 )

mkGuardBind :: Pattern dom -> Expr dom -> RhsGuard dom Source #

Creates a bind statement in a pattern guard ( Just v <- x )

mkGuardLet :: [LocalBind dom] -> RhsGuard dom Source #

Creates a let statement in a pattern guard ( let x = 3 )

mkGuardCheck :: Expr dom -> RhsGuard dom Source #

Creates an expression to check for a pattern guard