newDictsFromOld, newDicts, cloneDict,
newOverloadedLit, newIPDict,
newMethod, newMethodFromName, newMethodWithGivenTy,
- tcInstClassOp, tcInstCall, tcInstDataCon, tcSyntaxName,
+ tcInstClassOp, tcInstCall, tcInstDataCon,
+ tcSyntaxName, tcStdSyntaxName,
tyVarsOfInst, tyVarsOfInsts, tyVarsOfLIE,
ipNamesOfInst, ipNamesOfInsts, fdPredsOfInst, fdPredsOfInsts,
tcSyntaxName orig ty (std_nm, HsVar user_nm)
| std_nm == user_nm
- = newMethodFromName orig ty std_nm `thenM` \ id ->
- returnM (std_nm, HsVar id)
+ = tcStdSyntaxName orig ty std_nm
tcSyntaxName orig ty (std_nm, user_nm_expr)
= tcLookupId std_nm `thenM` \ std_id ->
tcCheckSigma user_nm_expr tau1 `thenM` \ expr ->
returnM (std_nm, expr)
+tcStdSyntaxName :: InstOrigin
+ -> TcType -- Type to instantiate it at
+ -> Name -- Standard name
+ -> TcM (Name, TcExpr) -- (Standard name, suitable expression)
+
+tcStdSyntaxName orig ty std_nm
+ = newMethodFromName orig ty std_nm `thenM` \ id ->
+ returnM (std_nm, HsVar id)
+
syntaxNameCtxt name orig ty tidy_env
= getInstLoc orig `thenM` \ inst_loc ->
let
import RdrHsSyn ( RdrNameHsModule, RdrNameHsDecl, RdrNameStmt, RdrNameHsExpr,
emptyGroup, mkGroup, findSplice, addImpDecls, main_RDR_Unqual )
-import PrelNames ( iNTERACTIVE, ioTyConName, printName,
- returnIOName, bindIOName, failIOName, thenIOName, runIOName,
+import PrelNames ( iNTERACTIVE, ioTyConName, printName, monadNames,
+ returnIOName, runIOName,
dollarMainName, itName, mAIN_Name, unsafeCoerceName
)
import MkId ( unsafeCoerceId )
mkForAllTys, mkFunTys, mkTyConApp, tcSplitForAllTys
)
import TcMatches ( tcStmtsAndThen, TcStmtCtxt(..) )
-import Inst ( showLIE )
+import Inst ( showLIE, tcStdSyntaxName )
import TcBinds ( tcTopBinds )
import TcClassDcl ( tcClassDecls2 )
import TcDefaults ( tcDefaults )
(ExplicitList placeHolderType (map mk_item names)) ;
mk_item name = HsApp (HsVar unsafeCoerceName) (HsVar name) ;
- all_stmts = stmts ++ [ret_stmt]
+ all_stmts = stmts ++ [ret_stmt] ;
+
+ io_ty = mkTyConApp ioTyCon []
} ;
-- OK, we're ready to typecheck the stmts
const_binds <- tcSimplifyTop lie ;
-- Build result expression and zonk it
- io_ids <- mappM mk_rebound
- [returnIOName, failIOName, bindIOName, thenIOName] ;
+ io_ids <- mappM (tcStdSyntaxName DoOrigin io_ty) monadNames ;
let { expr = mkHsLet const_binds $
HsDo DoExpr tc_stmts io_ids
(mkTyConApp ioTyCon [ret_ty]) noSrcLoc } ;
}
where
combine stmt (ids, stmts) = (ids, stmt:stmts)
- mk_rebound n = do { id <- tcLookupId n; return (n, HsVar id) }
- -- A bit hackoid
\end{code}