- full_local_global_prs = (private_binders `zip` poly_private_binders)
- ++ local_global_prs
- in
- listDs [ mkSatTyApp global tyvar_tys `thenDs` \ app ->
- returnDs (local, app)
- | (local,global) <- full_local_global_prs
- ] `thenDs` \ env ->
-
--- pprTrace "AbsBinds1:" (ppr PprDebug env) $
-
- extendEnvDs env (
-
- dsInstBinds tyvars inst_binds `thenDs` \ (inst_bind_pairs, inst_env) ->
- extendEnvDs inst_env (
-
- dsBind tyvars [] (lookupId full_local_global_prs) inst_bind_pairs val_binds
- ))
- where
- -- "private_binders" is the list of binders in val_binds
- -- which don't appear in the local_global_prs list
- -- These only really show up in stuff produced from compiling
- -- class and instance declarations.
- -- We need to add suitable polymorphic versions of them to the
- -- local_global_prs.
- private_binders = binders `minusList` [local | (local,_) <- local_global_prs]
- binders = collectTypedBinders val_binds
- mk_poly_private_binder id = newSysLocalDs (snd (quantifyTy tyvars (idType id)))
-
- tyvar_tys = mkTyVarTys tyvars
-\end{code}
-
-
-%==============================================
-\subsubsection{AbsBind case: overloading}
-%==============================================
-
-If there is overloading we go for the general case.
-
-We want the global identifiers to be abstracted wrt all types and
-dictionaries; and the local identifiers wrt the non-overloaded types.
-That is, we try to avoid global scoping of type abstraction. Example
-
- f :: Eq a => a -> [(a,b)] -> b
- f = ...f...
-
-Here, f is fully polymorphic in b. So we generate
-
- f ab d = let ...dict defns...
- in
- letrec f' b = ...(f' b)...
- in f' b
-
-*Notice* that we don't clone type variables, and *do* make use of
-shadowing. It is possible to do cloning, but it makes the code quite
-a bit more complicated, and the simplifier will clone it all anyway.
-
-Why bother with this gloss? Because it makes it more likely that
-the defn of f' can get floated out, notably if f gets specialised
-to a particular type for a.
-
-\begin{code}
-dsBinds (AbsBinds all_tyvars dicts local_global_prs dict_binds val_binds)
- = -- If there is any non-overloaded polymorphism, make new locals with
- -- appropriate polymorphism
- (if null non_overloaded_tyvars
- then
- -- No non-overloaded polymorphism, so stay with current envt
- returnDs (id, [], [])
- else
- -- Some local, non-overloaded polymorphism
- cloneTyVarsDs non_overloaded_tyvars `thenDs` \ local_tyvars ->
-
- mapDs mk_binder binders `thenDs` \ new_binders ->
- let
- old_new_pairs = binders `zip` new_binders
- in
-
- listDs [ mkSatTyApp new non_ov_tyvar_tys `thenDs` \ app ->
- returnDs (old, app)
- | (old,new) <- old_new_pairs
- ] `thenDs` \ extra_env ->
- let
- local_binds = [NonRec old app | (old,app) <- extra_env, old `is_elem` locals]
- is_elem = isIn "dsBinds"
- in
- returnDs (lookupId old_new_pairs, extra_env, local_binds)
- )
- `thenDs` \ (binder_subst_fn, local_env, local_binds) ->
-
--- pprTrace "AbsBinds:all:" (ppAbove (ppr PprDebug local_binds) (ppr PprDebug local_env)) $
-
- extendEnvDs local_env (
-
- dsInstBinds non_overloaded_tyvars dict_binds `thenDs` \ (inst_bind_pairs, inst_env) ->
-
- extendEnvDs inst_env (
-
- dsBind non_overloaded_tyvars [] binder_subst_fn inst_bind_pairs val_binds
- )) `thenDs` \ core_binds ->
-
+ -- Gross hack to prevent inlining into SpecPragmaId rhss
+ -- Consider fromIntegral = fromInteger . toInteger
+ -- spec1 = fromIntegral Int Float
+ -- Even though fromIntegral is small we don't want to inline
+ -- it inside spec1, so that we collect the specialised call
+ -- Solution: make spec1 an INLINE thing.
+ core_expr'' = mkInline (isSpecPragmaId var) core_expr'
+ in
+
+ returnDs ((var, core_expr'') : rest)
+
+dsHsBind auto_scc rest (FunBind (L _ fun) _ matches)
+ = matchWrapper (FunRhs (idName fun)) matches `thenDs` \ (args, body) ->
+ addAutoScc auto_scc (fun, mkLams args body) `thenDs` \ pair ->
+ returnDs (pair : rest)
+
+dsHsBind auto_scc rest (PatBind pat grhss ty)
+ = dsGuarded grhss ty `thenDs` \ body_expr ->
+ mkSelectorBinds pat body_expr `thenDs` \ sel_binds ->
+ mappM (addAutoScc auto_scc) sel_binds `thenDs` \ sel_binds ->
+ returnDs (sel_binds ++ rest)
+
+ -- Common special case: no type or dictionary abstraction
+ -- For the (rare) case when there are some mixed-up
+ -- dictionary bindings (for which a Rec is convenient)
+ -- we reply on the enclosing dsBind to wrap a Rec around.
+dsHsBind auto_scc rest (AbsBinds [] [] exports inlines binds)
+ = dsHsBinds (addSccs auto_scc exports) binds []`thenDs` \ core_prs ->