-@dsMonoBinds@ transforms @TypecheckedMonoBinds@ into @CoreBinds@.
-In addition to desugaring pattern matching, @dsMonoBinds@ takes
-a list of type variables and dicts, and adds abstractions for these
-to the front of every binding. That requires that the
-binders be altered too (their type has changed,
-so @dsMonoBinds@ also takes a function which maps binders into binders.
-This mapping gives the binder the correct new type.
-
-Remember, there's also a substitution in the monad which maps occurrences
-of these binders into applications of the new binder to suitable type variables
-and dictionaries.
-
-\begin{code}
-dsMonoBinds :: Bool -- True <=> add auto sccs
- -> Bool -- True <=> recursive binding group
- -> [TyVar] -> [DictVar] -- Abstract wrt these
- -> (Id -> Id) -- Binder substitution
- -> TypecheckedMonoBinds
- -> DsM [(Id,CoreExpr)]
-\end{code}
-
-
-
-%==============================================
-\subsubsection{Structure cases}
-%==============================================
-
-\begin{code}
-dsMonoBinds auto_scc is_rec tyvars dicts binder_subst EmptyMonoBinds = returnDs []
-
-dsMonoBinds auto_scc is_rec tyvars dicts binder_subst (AndMonoBinds binds_1 binds_2)
- = andDs (++) (dsMonoBinds auto_scc is_rec tyvars dicts binder_subst binds_1)
- (dsMonoBinds auto_scc is_rec tyvars dicts binder_subst binds_2)
-\end{code}
-
-
-%==============================================
-\subsubsection{Simple base cases: function and variable bindings}
-%==============================================
-
-\begin{code}
-dsMonoBinds auto_scc is_rec tyvars dicts binder_subst (VarMonoBind var expr)
- = dsExpr expr `thenDs` \ core_expr ->
- doSccAuto auto_scc [var] core_expr `thenDs` \ sccd_core_expr ->
- returnDs [(binder_subst var, mkLam tyvars dicts sccd_core_expr)]
-
-dsMonoBinds auto_scc is_rec tyvars dicts binder_subst (FunMonoBind fun _ matches locn)
- = putSrcLocDs locn $
- let
- new_fun = binder_subst fun
- error_string = "function " ++ showForErr fun
- in
- matchWrapper (FunMatch fun) matches error_string `thenDs` \ (args, body) ->
- doSccAuto auto_scc [fun] body `thenDs` \ sccd_body ->
- returnDs [(new_fun,
- mkLam tyvars (dicts ++ args) sccd_body)]
-
-dsMonoBinds auto_scc is_rec tyvars dicts binder_subst (PatMonoBind (VarPat v) grhss_and_binds locn)
- = putSrcLocDs locn $
- dsGuarded grhss_and_binds `thenDs` \ body_expr ->
- doSccAuto auto_scc [v] body_expr `thenDs` \ sccd_body_expr ->
- returnDs [(binder_subst v, mkLam tyvars dicts sccd_body_expr)]
-\end{code}
-
-%==============================================
-\subsubsection{The general base case}
-%==============================================
-
-Now the general case of a pattern binding. The monomorphism restriction
-should ensure that if there is a non-simple pattern binding in the
-group, then there is no overloading involved, so the dictionaries should
-be empty. (Simple pattern bindings were handled above.)
-First, the paranoia check.
-
-\begin{code}
-dsMonoBinds auto_scc is_rec tyvars (_:_) binder_subst (PatMonoBind pat grhss_and_binds locn)
- = panic "Non-empty dict list in for pattern binding"
-\end{code}
-
-We handle three cases for the binding
- pat = rhs
-
-\begin{description}
-\item[pat has no binders.]
-Then all this is dead code and we return an empty binding.
-
-\item[pat has exactly one binder, v.]
-Then we can transform to:
-\begin{verbatim}
- v' = /\ tyvars -> case rhs of { pat -> v }
-\end{verbatim}
-where \tr{v'} is gotten by looking up \tr{v} in the \tr{binder_subst}.
-
-\item[pat has more than one binder.]
-Then we transform to:
-\begin{verbatim}
- t = /\ tyvars -> case rhs of { pat -> (v1, ..., vn) }
-
- vi = /\ tyvars -> case (t tyvars) of { (v1, ..., vn) -> vi }
-\end{verbatim}
-\end{description}
-