import TcMonad
import Inst ( InstOrigin(..),
emptyLIE, plusLIE, LIE, mkLIE, unitLIE, instToId,
- newMethod, newOverloadedLit, newDicts, newClassDicts
+ newMethod, newOverloadedLit, newDicts
)
-import Id ( mkVanillaId )
+import Id ( mkLocalId )
import Name ( Name )
import FieldLabel ( fieldLabelName )
-import TcEnv ( tcLookupClass, tcLookupDataCon, tcLookupGlobalId )
-import TcType ( TcType, TcTyVar, tcInstTyVars, newTyVarTy )
-import TcMonoType ( tcHsSigType )
-import TcUnify ( unifyTauTy, unifyListTy, unifyTupleTy )
+import TcEnv ( tcLookupClass, tcLookupDataCon, tcLookupGlobalId, tcLookupId )
+import TcMType ( tcInstTyVars, newTyVarTy, unifyTauTy, unifyListTy, unifyTupleTy )
+import TcType ( isTauTy, mkTyConApp, mkClassPred, liftedTypeKind )
+import TcMonoType ( tcHsSigType, UserTypeCtxt(..) )
import CmdLineOpts ( opt_IrrefutableTuples )
import DataCon ( dataConSig, dataConFieldLabels,
dataConSourceArity
)
-import Type ( isTauTy, mkTyConApp, mkClassPred, liftedTypeKind )
-import Subst ( substTy, substClasses )
+import Subst ( substTy, substTheta )
import TysPrim ( charPrimTy, intPrimTy, floatPrimTy,
doublePrimTy, addrPrimTy
)
-- This is the right function to pass to tcPat when
-- we're looking at a lambda-bound pattern,
-- so there's no polymorphic guy to worry about
-tcMonoPatBndr binder_name pat_ty = returnTc (mkVanillaId binder_name pat_ty)
+tcMonoPatBndr binder_name pat_ty = returnTc (mkLocalId binder_name pat_ty)
\end{code}
= tcPat tc_bndr parend_pat pat_ty
tcPat tc_bndr (SigPatIn pat sig) pat_ty
- = tcHsSigType sig `thenTc` \ sig_ty ->
+ = tcHsSigType PatSigCtxt sig `thenTc` \ sig_ty ->
-- Check that the signature isn't a polymorphic one, which
-- we don't permit (at present, anyway)
where
origin = PatOrigin pat
lit' = case over_lit of
- HsIntegral i _ -> HsInteger i
+ HsIntegral i _ -> HsInteger i
HsFractional f _ -> HsRat f pat_ty
\end{code}
%************************************************************************
\begin{code}
-tcPat tc_bndr pat@(NPlusKPatIn name lit@(HsIntegral i _) minus) pat_ty
+tcPat tc_bndr pat@(NPlusKPatIn name lit@(HsIntegral i _) minus_name) pat_ty
= tc_bndr name pat_ty `thenTc` \ bndr_id ->
- tcLookupGlobalId minus `thenNF_Tc` \ minus_sel_id ->
+ -- The '-' part is re-mappable syntax
+ tcLookupId minus_name `thenNF_Tc` \ minus_sel_id ->
tcLookupGlobalId geName `thenNF_Tc` \ ge_sel_id ->
newOverloadedLit origin lit pat_ty `thenNF_Tc` \ (over_lit_expr, lie1) ->
newMethod origin ge_sel_id [pat_ty] `thenNF_Tc` \ ge ->
in
tcInstTyVars (ex_tvs ++ tvs) `thenNF_Tc` \ (all_tvs', ty_args', tenv) ->
let
- ex_theta' = substClasses tenv ex_theta
+ ex_theta' = substTheta tenv ex_theta
arg_tys' = map (substTy tenv) arg_tys
n_ex_tvs = length ex_tvs
ex_tvs' = take n_ex_tvs all_tvs'
result_ty = mkTyConApp tycon (drop n_ex_tvs ty_args')
in
- newClassDicts (PatOrigin pat) ex_theta' `thenNF_Tc` \ dicts ->
+ newDicts (PatOrigin pat) ex_theta' `thenNF_Tc` \ dicts ->
-- Check overall type matches
unifyTauTy pat_ty result_ty `thenTc_`