ghc-8.2.1.20171108: The GHC API

Safe HaskellNone
LanguageHaskell2010

HsUtils

Contents

Synopsis

Documentation

mkHsApp :: LHsExpr name -> LHsExpr name -> LHsExpr name Source #

mkHsAppType :: LHsExpr name -> LHsWcType name -> LHsExpr name Source #

mkHsCaseAlt :: LPat id -> Located (body id) -> LMatch id (Located (body id)) Source #

A simple case alternative with a single pattern, no binds, no guards; pre-typechecking

mkSimpleMatch :: HsMatchContext (NameOrRdrName id) -> [LPat id] -> Located (body id) -> LMatch id (Located (body id)) Source #

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

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

mkMatchGroup :: PostTc name Type ~ PlaceHolder => Origin -> [LMatch name (Located (body name))] -> MatchGroup name (Located (body name)) Source #

mkPrefixFunRhs :: Located id -> HsMatchContext id Source #

Make a prefix, non-strict function HsMatchContext

mkHsIf :: LHsExpr id -> LHsExpr id -> LHsExpr id -> HsExpr id Source #

mkHsOpApp :: LHsExpr id -> id -> LHsExpr id -> HsExpr id Source #

mkLHsPar :: LHsExpr name -> LHsExpr name Source #

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

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

nlHsVar :: id -> LHsExpr id Source #

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

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

nlHsOpApp :: LHsExpr id -> id -> LHsExpr id -> LHsExpr id Source #

nlHsIf :: LHsExpr id -> LHsExpr id -> LHsExpr id -> LHsExpr id Source #

typeToLHsType :: Type -> LHsType RdrName Source #

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

GHCs built in tuples can only go up to mAX_TUPLE_SIZE in arity, but we might concievably want to build such a massive tuple as part of the output of a desugaring stage (notably that for list comprehensions).

We call tuples above this size "big tuples", and emulate them by creating and pattern matching on >nested< tuples that are expressible by GHC.

Nesting policy: it's better to have a 2-tuple of 10-tuples (3 objects) than a 10-tuple of 2-tuples (11 objects), so we want the leaves of any construction to be big.

If you just use the mkBigCoreTup, mkBigCoreVarTupTy, mkTupleSelector and mkTupleCase functions to do all your work with tuples you should be fine, and not have to worry about the arity limitation at all.

mkChunkified Source #

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]] Source #

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 Source #

isInfixFunBind :: HsBindLR id1 id2 -> Bool Source #

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

nlVarPat :: id -> LPat id Source #

nlInfixConPat :: id -> LPat id -> LPat id -> LPat id Source #

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

mkParPat :: LPat name -> LPat name Source #

nlParPat :: LPat name -> LPat name Source #

mkHsAppTy :: LHsType name -> LHsType name -> LHsType name Source #

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

mkHsSigEnv :: forall a. (LSig Name -> Maybe ([Located Name], a)) -> [LSig Name] -> NameEnv a Source #

nlHsAppTy :: LHsType name -> LHsType name -> LHsType name Source #

nlHsTyVar :: name -> LHsType name Source #

nlHsFunTy :: LHsType name -> LHsType name -> LHsType name Source #

nlHsParTy :: LHsType name -> LHsType name Source #

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

mkTransformStmt :: PostTc idR Type ~ PlaceHolder => [ExprLStmt idL] -> LHsExpr idR -> StmtLR idL idR (LHsExpr idL) Source #

mkTransformByStmt :: PostTc idR Type ~ PlaceHolder => [ExprLStmt idL] -> LHsExpr idR -> LHsExpr idR -> StmtLR idL idR (LHsExpr idL) Source #

mkBindStmt :: PostTc idR Type ~ PlaceHolder => LPat idL -> Located (bodyR idR) -> StmtLR idL idR (Located (bodyR idR)) Source #

mkTcBindStmt :: LPat Id -> Located (bodyR Id) -> StmtLR Id Id (Located (bodyR Id)) Source #

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

mkGroupUsingStmt :: PostTc idR Type ~ PlaceHolder => [ExprLStmt idL] -> LHsExpr idR -> StmtLR idL idR (LHsExpr idL) Source #

mkGroupByUsingStmt :: PostTc idR Type ~ PlaceHolder => [ExprLStmt idL] -> LHsExpr idR -> LHsExpr idR -> StmtLR idL idR (LHsExpr idL) Source #

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

isUnliftedHsBind :: HsBind Id -> Bool Source #

Should we treat this as an unlifted bind? This will be true for any bind that binds an unlifted variable, but we must be careful around AbsBinds. See Note [Unlifted id check in isUnliftedHsBind]. For usage information, see Note [Strict binds check] is DsBinds.

isBangedBind :: HsBind Id -> Bool Source #

Is a binding a strict variable bind (e.g. !x = ...)?

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

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

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

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

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

Returns all the binding names of the decl. The first one is