Commit 6288438b authored by simonpj's avatar simonpj
Browse files

[project @ 1999-06-28 16:32:00 by simonpj]

Propagate changes for tcSimplifyToDicts
parent 46ebcd57
......@@ -13,7 +13,7 @@ import HsCore ( UfRuleBody(..) )
import RnHsSyn ( RenamedHsDecl )
import TcHsSyn ( TypecheckedRuleDecl, mkHsLet )
import TcMonad
import TcSimplify ( tcSimplifyRuleLhs, tcSimplifyAndCheck )
import TcSimplify ( tcSimplifyToDicts, tcSimplifyAndCheck )
import TcType ( zonkTcTypes, newTyVarTy_OpenKind )
import TcIfaceSig ( tcCoreExpr, tcCoreLamBndrs, tcVar )
import TcMonoType ( tcHsType, tcHsTyVar, checkSigTyVars )
......@@ -66,7 +66,7 @@ tcRule (RuleDecl name sig_tvs vars lhs rhs src_loc)
) `thenTc` \ (ids, lhs', rhs', lhs_lie, rhs_lie) ->
-- Check that LHS has no overloading at all
tcSimplifyRuleLhs lhs_lie `thenTc` \ (lhs_dicts, lhs_binds) ->
tcSimplifyToDicts lhs_lie `thenTc` \ (lhs_dicts, lhs_binds) ->
checkSigTyVars sig_tyvars `thenTc_`
-- Gather the template variables and tyvars
......
......@@ -116,7 +116,7 @@ and hence the default mechanism would resolve the "a".
\begin{code}
module TcSimplify (
tcSimplify, tcSimplifyAndCheck, tcSimplifyRuleLhs,
tcSimplify, tcSimplifyAndCheck, tcSimplifyToDicts,
tcSimplifyTop, tcSimplifyThetas, tcSimplifyCheckThetas,
bindInstsOfLocalFuns
) where
......@@ -293,10 +293,27 @@ On the LHS of transformation rules we only simplify methods and constants,
getting dictionaries. We want to keep all of them unsimplified, to serve
as the available stuff for the RHS of the rule.
The same thing is used for specialise pragmas. Consider
f :: Num a => a -> a
{-# SPECIALISE f :: Int -> Int #-}
f = ...
The type checker generates a binding like:
f_spec = (f :: Int -> Int)
and we want to end up with
f_spec = _inline_me_ (f Int dNumInt)
But that means that we must simplify the Method for f to (f Int dNumInt)!
So tcSimplifyToDicts squeezes out all Methods.
\begin{code}
tcSimplifyRuleLhs :: LIE -> TcM s (LIE, TcDictBinds)
tcSimplifyRuleLhs wanted_lie
= reduceContext (text "tcSimplRuleLhs") try_me [] wanteds `thenTc` \ (binds, frees, irreds) ->
tcSimplifyToDicts :: LIE -> TcM s (LIE, TcDictBinds)
tcSimplifyToDicts wanted_lie
= reduceContext (text "tcSimplifyToDicts") try_me [] wanteds `thenTc` \ (binds, frees, irreds) ->
ASSERT( null frees )
returnTc (mkLIE irreds, binds)
where
......@@ -308,6 +325,7 @@ tcSimplifyRuleLhs wanted_lie
\end{code}
%************************************************************************
%* *
\subsection{Data types for the reduction mechanism}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment