ghc-8.0.0.20160111: The GHC API

Safe HaskellNone
LanguageHaskell2010

HsUtils

Contents

Synopsis

Documentation

mkHsPar :: LHsExpr id -> LHsExpr id

mkHsApp :: LHsExpr name -> LHsExpr name -> LHsExpr name

mkSimpleHsAlt :: LPat id -> Located (body id) -> LMatch id (Located (body id))

mkSimpleMatch :: [LPat id] -> Located (body id) -> LMatch id (Located (body id))

unguardedGRHSs :: Located (body id) -> GRHSs id (Located (body id))

unguardedRHS :: SrcSpan -> Located (body id) -> [LGRHS id (Located (body id))]

mkMatch :: [LPat id] -> LHsExpr id -> Located (HsLocalBinds id) -> LMatch id (LHsExpr id)

mkHsIf :: LHsExpr id -> LHsExpr id -> LHsExpr id -> HsExpr id

mkHsOpApp :: LHsExpr id -> id -> LHsExpr id -> HsExpr id

mkHsWrapPat :: HsWrapper -> Pat id -> Type -> Pat id

mkLHsPar :: LHsExpr name -> LHsExpr name

isLHsTypeExpr_maybe :: LHsExpr name -> Maybe (LHsWcType name)

Extract a type argument from an HsExpr, with the list of wildcards in the type

isLHsTypeExpr :: LHsExpr name -> Bool

Is an expression a visible type application?

nlHsTyApp :: name -> [Type] -> LHsExpr name

nlHsTyApps :: name -> [Type] -> [LHsExpr name] -> LHsExpr name

nlHsVar :: id -> LHsExpr id

nlHsApp :: LHsExpr id -> LHsExpr id -> LHsExpr id

nlHsApps :: id -> [LHsExpr id] -> LHsExpr id

nlHsVarApps :: id -> [id] -> LHsExpr id

nlHsOpApp :: LHsExpr id -> id -> LHsExpr id -> LHsExpr id

nlHsPar :: LHsExpr id -> LHsExpr id

nlHsIf :: LHsExpr id -> LHsExpr id -> LHsExpr id -> LHsExpr id

toLHsSigWcType :: Type -> LHsSigWcType RdrName

Converting a Type to an HsType RdrName This is needed to implement GeneralizedNewtypeDeriving.

Note that we use getRdrName extensively, which generates Exact RdrNames rather than strings.

Constructing general big tuples

 

mkChunkified

Arguments

:: ([a] -> a)

"Small" constructor function, of maximum input arity mAX_TUPLE_SIZE

-> [a]

Possible "big" list of things to construct from

-> a

Constructed thing made possible by recursive decomposition

Lifts a "small" constructor into a "big" constructor by recursive decompositon

chunkify :: [a] -> [[a]]

Split a list into lists that are small enough to have a corresponding tuple arity. The sub-lists of the result all have length <= mAX_TUPLE_SIZE But there may be more than mAX_TUPLE_SIZE sub-lists

mkVarBind :: id -> LHsExpr id -> LHsBind id

isInfixFunBind :: HsBindLR id1 id2 -> Bool

If any of the matches in the FunBind are infix, the FunBind is considered infix.

mkNPat :: Located (HsOverLit id) -> Maybe (SyntaxExpr id) -> Pat id

nlVarPat :: id -> LPat id

nlInfixConPat :: id -> LPat id -> LPat id -> LPat id

nlNullaryConPat :: id -> LPat id

nlTuplePat :: [LPat id] -> Boxity -> LPat id

mkParPat :: LPat name -> LPat name

mkBigLHsVarTup :: [id] -> LHsExpr id

mkBigLHsVarPatTup :: [id] -> LPat id

mkBigLHsPatTup :: [LPat id] -> LPat id

mkHsAppTy :: LHsType name -> LHsType name -> LHsType name

mkHsAppTys :: LHsType name -> [LHsType name] -> LHsType name

userHsTyVarBndrs :: SrcSpan -> [name] -> [LHsTyVarBndr name]

nlHsAppTy :: LHsType name -> LHsType name -> LHsType name

nlHsTyVar :: name -> LHsType name

nlHsFunTy :: LHsType name -> LHsType name -> LHsType name

nlHsTyConApp :: name -> [LHsType name] -> LHsType name

getAppsTyHead_maybe :: [LHsAppType name] -> Maybe (LHsType name, [LHsType name])

Retrieves the head of an HsAppsTy, if this can be done unambiguously, without consulting fixities.

splitHsAppsTy :: [LHsAppType name] -> ([[LHsType name]], [Located name])

Splits a [HsAppType name] (the payload of an HsAppsTy) into regions of prefix types (normal types) and infix operators. If splitHsAppsTy tys = (non_syms, syms), then tys starts with the first element of non_syms followed by the first element of syms followed by the next element of non_syms, etc. It is guaranteed that the non_syms list has one more element than the syms list.

mkTransformStmt :: [ExprLStmt idL] -> LHsExpr idR -> StmtLR idL idR (LHsExpr idL)

mkTransformByStmt :: [ExprLStmt idL] -> LHsExpr idR -> LHsExpr idR -> StmtLR idL idR (LHsExpr idL)

mkBodyStmt :: Located (bodyR RdrName) -> StmtLR idL RdrName (Located (bodyR RdrName))

mkBindStmt :: LPat idL -> Located (bodyR idR) -> StmtLR idL idR (Located (bodyR idR))

mkLastStmt :: Located (bodyR idR) -> StmtLR idL idR (Located (bodyR idR))

emptyTransStmt :: StmtLR idL idR (LHsExpr idR)

mkGroupUsingStmt :: [ExprLStmt idL] -> LHsExpr idR -> StmtLR idL idR (LHsExpr idL)

mkGroupByUsingStmt :: [ExprLStmt idL] -> LHsExpr idR -> LHsExpr idR -> StmtLR idL idR (LHsExpr idL)

mkRecStmt :: [LStmtLR idL RdrName bodyR] -> StmtLR idL RdrName bodyR

collectHsValBinders :: HsValBindsLR idL idR -> [idL]

collectHsBindListBinders :: [LHsBindLR idL idR] -> [idL]

collectHsIdBinders :: HsValBindsLR idL idR -> [idL]

collectHsBindsBinders :: LHsBindsLR idL idR -> [idL]

collectHsBindBinders :: HsBindLR idL idR -> [idL]

collectPatsBinders :: [LPat a] -> [a]

collectLStmtsBinders :: [LStmtLR idL idR body] -> [idL]

collectStmtsBinders :: [StmtLR idL idR body] -> [idL]

collectLStmtBinders :: LStmtLR idL idR body -> [idL]

collectStmtBinders :: StmtLR idL idR body -> [idL]

hsLTyClDeclBinders :: Located (TyClDecl name) -> ([Located name], [LFieldOcc name])

Returns all the binding names of the decl. The first one is guaranteed to be the name of the decl. The first component represents all binding names except record fields; the second represents field occurrences. For record fields mentioned in multiple constructors, the SrcLoc will be from the first occurrence.

Each returned (Located name) has a SrcSpan for the whole declaration. See Note [SrcSpan for binders]

lStmtsImplicits :: [LStmtLR Name idR (Located (body idR))] -> NameSet