ghc-7.10.2: The GHC API

Safe Haskell | None
Language | Haskell2010

HsBinds

Synopsis

- type HsLocalBinds id = HsLocalBindsLR id id
- data HsLocalBindsLR idL idR
  - = HsValBinds (HsValBindsLR idL idR)
  - | HsIPBinds (HsIPBinds idR)
  - | EmptyLocalBinds
- type HsValBinds id = HsValBindsLR id id
- data HsValBindsLR idL idR
  - = ValBindsIn (LHsBindsLR idL idR) [LSig idR]
  - | ValBindsOut [(RecFlag, LHsBinds idL)] [LSig Name]
- type LHsBind id = LHsBindLR id id
- type LHsBinds id = LHsBindsLR id id
- type HsBind id = HsBindLR id id
- type LHsBindsLR idL idR = Bag (LHsBindLR idL idR)
- type LHsBindLR idL idR = Located (HsBindLR idL idR)
- data HsBindLR idL idR
  - = FunBind {
    - fun_id :: Located idL
    - fun_infix :: Bool
    - fun_matches :: MatchGroup idR (LHsExpr idR)
    - fun_co_fn :: HsWrapper
    - bind_fvs :: PostRn idL NameSet
    - fun_tick :: [Tickish Id]
    }
  - | PatBind {
    - pat_lhs :: LPat idL
    - pat_rhs :: GRHSs idR (LHsExpr idR)
    - pat_rhs_ty :: PostTc idR Type
    - bind_fvs :: PostRn idL NameSet
    - pat_ticks :: ([Tickish Id], [[Tickish Id]])
    }
  - | VarBind {
    - var_id :: idL
    - var_rhs :: LHsExpr idR
    - var_inline :: Bool
    }
  - | AbsBinds {
    - abs_tvs :: [TyVar]
    - abs_ev_vars :: [EvVar]
    - abs_exports :: [ABExport idL]
    - abs_ev_binds :: TcEvBinds
    - abs_binds :: LHsBinds idL
    }
  - | PatSynBind (PatSynBind idL idR)
- data ABExport id = ABE {
  - abe_poly :: id
  - abe_mono :: id
  - abe_wrap :: HsWrapper
  - abe_prags :: TcSpecPrags
  }
- data PatSynBind idL idR = PSB {
  - psb_id :: Located idL
  - psb_fvs :: PostRn idR NameSet
  - psb_args :: HsPatSynDetails (Located idR)
  - psb_def :: LPat idR
  - psb_dir :: HsPatSynDir idR
  }
- pprLHsBinds :: (OutputableBndr idL, OutputableBndr idR) => LHsBindsLR idL idR -> SDoc
- pprLHsBindsForUser :: (OutputableBndr idL, OutputableBndr idR, OutputableBndr id2) => LHsBindsLR idL idR -> [LSig id2] -> [SDoc]
- pprDeclList :: [SDoc] -> SDoc
- emptyLocalBinds :: HsLocalBindsLR a b
- isEmptyLocalBinds :: HsLocalBindsLR a b -> Bool
- isEmptyValBinds :: HsValBindsLR a b -> Bool
- emptyValBindsIn :: HsValBindsLR a b
- emptyValBindsOut :: HsValBindsLR a b
- emptyLHsBinds :: LHsBindsLR idL idR
- isEmptyLHsBinds :: LHsBindsLR idL idR -> Bool
- plusHsValBinds :: HsValBinds a -> HsValBinds a -> HsValBinds a
- getTypeSigNames :: HsValBinds a -> NameSet
- ppr_monobind :: (OutputableBndr idL, OutputableBndr idR) => HsBindLR idL idR -> SDoc
- pprTicks :: SDoc -> SDoc -> SDoc
- data HsIPBinds id = IPBinds [LIPBind id] TcEvBinds
- isEmptyIPBinds :: HsIPBinds id -> Bool
- type LIPBind id = Located (IPBind id)
- data IPBind id = IPBind (Either (Located HsIPName) id) (LHsExpr id)
- type LSig name = Located (Sig name)
- data Sig name
  - = TypeSig [Located name] (LHsType name) (PostRn name [Name])
  - | PatSynSig (Located name) (HsExplicitFlag, LHsTyVarBndrs name) (LHsContext name) (LHsContext name) (LHsType name)
  - | GenericSig [Located name] (LHsType name)
  - | IdSig Id
  - | FixSig (FixitySig name)
  - | InlineSig (Located name) InlinePragma
  - | SpecSig (Located name) [LHsType name] InlinePragma
  - | SpecInstSig SourceText (LHsType name)
  - | MinimalSig SourceText (BooleanFormula (Located name))
- type LFixitySig name = Located (FixitySig name)
- data FixitySig name = FixitySig [Located name] Fixity
- data TcSpecPrags
  - = IsDefaultMethod
  - | SpecPrags [LTcSpecPrag]
- type LTcSpecPrag = Located TcSpecPrag
- data TcSpecPrag = SpecPrag Id HsWrapper InlinePragma
- noSpecPrags :: TcSpecPrags
- hasSpecPrags :: TcSpecPrags -> Bool
- isDefaultMethod :: TcSpecPrags -> Bool
- isFixityLSig :: LSig name -> Bool
- isVanillaLSig :: LSig name -> Bool
- isTypeLSig :: LSig name -> Bool
- isSpecLSig :: LSig name -> Bool
- isSpecInstLSig :: LSig name -> Bool
- isPragLSig :: LSig name -> Bool
- isInlineLSig :: LSig name -> Bool
- isMinimalLSig :: LSig name -> Bool
- hsSigDoc :: Sig name -> SDoc
- ppr_sig :: OutputableBndr name => Sig name -> SDoc
- pprPatSynSig :: OutputableBndr name => name -> Bool -> SDoc -> Maybe SDoc -> Maybe SDoc -> SDoc -> SDoc
- pragBrackets :: SDoc -> SDoc
- pprVarSig :: OutputableBndr id => [id] -> SDoc -> SDoc
- pprSpec :: OutputableBndr id => id -> SDoc -> InlinePragma -> SDoc
- pprTcSpecPrags :: TcSpecPrags -> SDoc
- pprMinimalSig :: OutputableBndr name => BooleanFormula (Located name) -> SDoc
- data HsPatSynDetails a
  - = InfixPatSyn a a
  - | PrefixPatSyn [a]
- data HsPatSynDir id
  - = Unidirectional
  - | ImplicitBidirectional
  - | ExplicitBidirectional (MatchGroup id (LHsExpr id))

# Documentation

type HsLocalBinds id = HsLocalBindsLR id id Source

data HsLocalBindsLR idL idR Source

Bindings in a 'let' expression or a 'where' clause

Constructors

HsValBinds (HsValBindsLR idL idR) |
HsIPBinds (HsIPBinds idR) |
EmptyLocalBinds |

Instances

(DataId idL, DataId idR) => Data (HsLocalBindsLR idL idR) |
(OutputableBndr idL, OutputableBndr idR) => Outputable (HsLocalBindsLR idL idR) |

type HsValBinds id = HsValBindsLR id id Source

data HsValBindsLR idL idR Source

Value bindings (not implicit parameters) Used for both top level and nested bindings May contain pattern synonym bindings

Constructors

ValBindsIn (LHsBindsLR idL idR) [LSig idR] | Before renaming RHS; idR is always RdrName Not dependency analysed Recursive by default
ValBindsOut [(RecFlag, LHsBinds idL)] [LSig Name] | After renaming RHS; idR can be Name or Id Dependency analysed, later bindings in the list may depend on earlier ones.

Instances

(DataId idL, DataId idR) => Data (HsValBindsLR idL idR) |
(OutputableBndr idL, OutputableBndr idR) => Outputable (HsValBindsLR idL idR) |

type LHsBind id = LHsBindLR id id Source

type LHsBinds id = LHsBindsLR id id Source

type HsBind id = HsBindLR id id Source

type LHsBindsLR idL idR = Bag (LHsBindLR idL idR) Source

type LHsBindLR idL idR = Located (HsBindLR idL idR) Source

data HsBindLR idL idR Source

Constructors

FunBind | FunBind is used for both functions `f x = e` and variables `f = x -> e` Reason 1: Special case for type inference: see `tcMonoBinds`. Reason 2: Instance decls can only have FunBinds, which is convenient. If you change this, you'll need to change e.g. rnMethodBinds But note that the form `f :: a->a = ...` parses as a pattern binding, just like `(f :: a -> a) = ...` `AnnKeywordId`s `AnnFunId`, attached to each element of fun_matches `AnnEqual`,`AnnWhere`, `AnnOpen`,`AnnClose`,
  Fields fun_id :: Located idL fun_infix :: Bool True => infix declaration fun_matches :: MatchGroup idR (LHsExpr idR) The payload fun_co_fn :: HsWrapper Coercion from the type of the MatchGroup to the type of the Id. Example:
           f :: Int -> forall a. a -> a
           f x y = y
Then the MatchGroup will have type (Int -> a' -> a') (with a free type variable a'). The coercion will take a CoreExpr of this type and convert it to a CoreExpr of type Int -> forall a'. a' -> a' Notice that the coercion captures the free a'. bind_fvs :: PostRn idL NameSet After the renamer, this contains the locally-bound free variables of this defn. See Note [Bind free vars] fun_tick :: [Tickish Id] Ticks to put on the rhs, if any
PatBind | The pattern is never a simple variable; That case is done by FunBind `AnnKeywordId` : `AnnBang`, `AnnEqual`,`AnnWhere`, `AnnOpen`,`AnnClose`,
Fields pat_lhs :: LPat idL pat_rhs :: GRHSs idR (LHsExpr idR) pat_rhs_ty :: PostTc idR Type Type of the GRHSs bind_fvs :: PostRn idL NameSet After the renamer, this contains the locally-bound free variables of this defn. See Note [Bind free vars] pat_ticks :: ([Tickish Id], [[Tickish Id]]) Ticks to put on the rhs, if any, and ticks to put on the bound variables.
VarBind | Dictionary binding and suchlike. All VarBinds are introduced by the type checker
Fields var_id :: idL var_rhs :: LHsExpr idR Located only for consistency var_inline :: Bool True = inline this binding regardless (used for implication constraints only)
AbsBinds |
Fields abs_tvs :: [TyVar] abs_ev_vars :: [EvVar] Includes equality constraints abs_exports :: [ABExport idL] AbsBinds only gets used when idL = idR after renaming, but these need to be idL's for the collect... code in HsUtil to have the right type abs_ev_binds :: TcEvBinds Evidence bindings abs_binds :: LHsBinds idL Typechecked user bindings
PatSynBind (PatSynBind idL idR) | `AnnKeywordId` : `AnnPattern`, `AnnLarrow`,`AnnEqual`, `AnnWhere` `AnnOpen` `'{'`,`AnnClose` `'}'`

Instances

(DataId idL, DataId idR) => Data (HsBindLR idL idR) |
(OutputableBndr idL, OutputableBndr idR) => Outputable (HsBindLR idL idR) |

data ABExport id Source

Constructors

ABE |
Fields abe_poly :: id Any INLINE pragmas is attached to this Id abe_mono :: id abe_wrap :: HsWrapper See Note [AbsBinds wrappers] Shape: (forall abs_tvs. abs_ev_vars => abe_mono) ~ abe_poly abe_prags :: TcSpecPrags SPECIALISE pragmas

Instances

Data id => Data (ABExport id) |
OutputableBndr id => Outputable (ABExport id) |

data PatSynBind idL idR Source

- `AnnKeywordId` : `AnnPattern`, `AnnEqual`,`AnnLarrow` `AnnWhere`,`AnnOpen` `'{'`, `AnnClose` `'}'`,

Constructors

PSB |
Fields psb_id :: Located idL Name of the pattern synonym psb_fvs :: PostRn idR NameSet See Note [Bind free vars] psb_args :: HsPatSynDetails (Located idR) Formal parameter names psb_def :: LPat idR Right-hand side psb_dir :: HsPatSynDir idR Directionality

Instances

(DataId idL, DataId idR) => Data (PatSynBind idL idR) |
(OutputableBndr idL, OutputableBndr idR) => Outputable (PatSynBind idL idR) |

pprLHsBinds :: (OutputableBndr idL, OutputableBndr idR) => LHsBindsLR idL idR -> SDoc Source

pprLHsBindsForUser :: (OutputableBndr idL, OutputableBndr idR, OutputableBndr id2) => LHsBindsLR idL idR -> [LSig id2] -> [SDoc] Source

pprDeclList :: [SDoc] -> SDoc Source

emptyLocalBinds :: HsLocalBindsLR a b Source

isEmptyLocalBinds :: HsLocalBindsLR a b -> Bool Source

isEmptyValBinds :: HsValBindsLR a b -> Bool Source

emptyValBindsIn :: HsValBindsLR a b Source

emptyValBindsOut :: HsValBindsLR a b Source

emptyLHsBinds :: LHsBindsLR idL idR Source

isEmptyLHsBinds :: LHsBindsLR idL idR -> Bool Source

plusHsValBinds :: HsValBinds a -> HsValBinds a -> HsValBinds a Source

getTypeSigNames :: HsValBinds a -> NameSet Source

ppr_monobind :: (OutputableBndr idL, OutputableBndr idR) => HsBindLR idL idR -> SDoc Source

pprTicks :: SDoc -> SDoc -> SDoc Source

data HsIPBinds id Source

Constructors

IPBinds [LIPBind id] TcEvBinds |

Instances

DataId id => Data (HsIPBinds id) |
OutputableBndr id => Outputable (HsIPBinds id) |

isEmptyIPBinds :: HsIPBinds id -> Bool Source

type LIPBind id = Located (IPBind id) Source

May have `AnnKeywordId` : `AnnSemi` when in a list

data IPBind id Source

Implicit parameter bindings.

These bindings start off as (Left "x") in the parser and stay that way until after type-checking when they are replaced with (Right d), where "d" is the name of the dictionary holding the evidence for the implicit parameter.

- `AnnKeywordId` : `AnnEqual`

Constructors

IPBind (Either (Located HsIPName) id) (LHsExpr id) |

Instances

DataId name => Data (IPBind name) |
OutputableBndr id => Outputable (IPBind id) |

type LSig name = Located (Sig name) Source

data Sig name Source

Signatures and pragmas

Constructors

TypeSig [Located name] (LHsType name) (PostRn name [Name]) | An ordinary type signature
    f :: Num a => a -> a
After renaming, this list of Names contains the named and unnamed wildcards brought into scope by this signature. For a signature `_ -> _a -> Bool`, the renamer will give the unnamed wildcard `_` a freshly generated name, e.g. `_w`. `_w` and the named wildcard `_a` are then both replaced with fresh meta vars in the type. Their names are stored in the type signature that brought them into scope, in this third field to be more specific. `AnnKeywordId` : `AnnDcolon`, `AnnComma`
PatSynSig (Located name) (HsExplicitFlag, LHsTyVarBndrs name) (LHsContext name) (LHsContext name) (LHsType name) | A pattern synonym type signature
    pattern Single :: () => (Show a) => a -> [a]
`AnnKeywordId` : `AnnPattern`, `AnnDcolon`,`AnnForall` `AnnDot`,`AnnDarrow`
GenericSig [Located name] (LHsType name) | A type signature for a default method inside a class
    default eq :: (Representable0 a, GEq (Rep0 a)) => a -> a -> Bool
`AnnKeywordId` : `AnnDefault`, `AnnDcolon`
IdSig Id | A type signature in generated code, notably the code generated for record selectors. We simply record the desired Id itself, replete with its name, type and IdDetails. Otherwise it's just like a type signature: there should be an accompanying binding
FixSig (FixitySig name) | An ordinary fixity declaration
        infixl 8 ***
`AnnKeywordId` : `AnnInfix`, `AnnVal`
InlineSig (Located name) InlinePragma | An inline pragma
    {#- INLINE f #-}
`AnnKeywordId` : `AnnOpen` `'{-# INLINE'` and `'['`, `AnnClose`,`AnnOpen`, `AnnVal`,`AnnTilde`, `AnnClose`
SpecSig (Located name) [LHsType name] InlinePragma | A specialisation pragma
    {-# SPECIALISE f :: Int -> Int #-}
`AnnKeywordId` : `AnnOpen`, `AnnOpen` `'{-# SPECIALISE'` and `'['`, `AnnTilde`, `AnnVal`, `AnnClose` `']'` and `'#-}'`, `AnnDcolon`
SpecInstSig SourceText (LHsType name) | A specialisation pragma for instance declarations only
    {-# SPECIALISE instance Eq [Int] #-}
(Class tys); should be a specialisation of the current instance declaration `AnnKeywordId` : `AnnOpen`, `AnnInstance`,`AnnClose`
MinimalSig SourceText (BooleanFormula (Located name)) | A minimal complete definition pragma
    {-# MINIMAL a | (b, c | (d | e)) #-}
`AnnKeywordId` : `AnnOpen`, `AnnVbar`,`AnnComma`, `AnnClose`

Instances

DataId name => Data (Sig name) |
OutputableBndr name => Outputable (Sig name) |

type LFixitySig name = Located (FixitySig name) Source

data FixitySig name Source

Constructors

FixitySig [Located name] Fixity |

Instances

Data name => Data (FixitySig name) |
OutputableBndr name => Outputable (FixitySig name) |

data TcSpecPrags Source

TsSpecPrags conveys pragmas from the type checker to the desugarer

Constructors

IsDefaultMethod | Super-specialised: a default method should be macro-expanded at every call site
SpecPrags [LTcSpecPrag] |

Instances

Data TcSpecPrags |

type LTcSpecPrag = Located TcSpecPrag Source

data TcSpecPrag Source

Constructors

SpecPrag Id HsWrapper InlinePragma | The Id to be specialised, an wrapper that specialises the polymorphic function, and inlining spec for the specialised function

Instances

Data TcSpecPrag |
Outputable TcSpecPrag |

noSpecPrags :: TcSpecPrags Source

hasSpecPrags :: TcSpecPrags -> Bool Source

isDefaultMethod :: TcSpecPrags -> Bool Source

isFixityLSig :: LSig name -> Bool Source

isVanillaLSig :: LSig name -> Bool Source

isTypeLSig :: LSig name -> Bool Source

isSpecLSig :: LSig name -> Bool Source

isSpecInstLSig :: LSig name -> Bool Source

isPragLSig :: LSig name -> Bool Source

isInlineLSig :: LSig name -> Bool Source

isMinimalLSig :: LSig name -> Bool Source

hsSigDoc :: Sig name -> SDoc Source

ppr_sig :: OutputableBndr name => Sig name -> SDoc Source

pprPatSynSig :: OutputableBndr name => name -> Bool -> SDoc -> Maybe SDoc -> Maybe SDoc -> SDoc -> SDoc Source

pragBrackets :: SDoc -> SDoc Source

pprVarSig :: OutputableBndr id => [id] -> SDoc -> SDoc Source

pprSpec :: OutputableBndr id => id -> SDoc -> InlinePragma -> SDoc Source

pprTcSpecPrags :: TcSpecPrags -> SDoc Source

pprMinimalSig :: OutputableBndr name => BooleanFormula (Located name) -> SDoc Source

data HsPatSynDetails a Source

Constructors

InfixPatSyn a a |
PrefixPatSyn [a] |

Instances

Functor HsPatSynDetails |
Foldable HsPatSynDetails |
Traversable HsPatSynDetails |
Data a => Data (HsPatSynDetails a) |

data HsPatSynDir id Source

Constructors

Unidirectional |
ImplicitBidirectional |
ExplicitBidirectional (MatchGroup id (LHsExpr id)) |

Instances

DataId id => Data (HsPatSynDir id) |