+
+tcCoreExpr (UfNote note expr)
+ = tcCoreExpr expr `thenTc` \ expr' ->
+ case note of
+ UfCoerce to_ty -> tcHsType to_ty `thenTc` \ to_ty' ->
+ returnTc (Note (Coerce (unUsgTy to_ty')
+ (unUsgTy (coreExprType expr'))) expr')
+ UfInlineCall -> returnTc (Note InlineCall expr')
+ UfInlineMe -> returnTc (Note InlineMe expr')
+ UfSCC cc -> returnTc (Note (SCC cc) expr')
+
+tcCoreNote (UfSCC cc) = returnTc (SCC cc)
+tcCoreNote UfInlineCall = returnTc InlineCall
+
+
+----------------------------------
+tcUfCon (UfLitCon lit) args
+ = ASSERT( null args)
+ tcUfLit lit `thenTc` \ lit ->
+ returnTc (Con (Literal lit) [])
+
+-- The dreaded lit-lits are also similar, except here the type
+-- is read in explicitly rather than being implicit
+tcUfCon (UfLitLitCon lit ty) args
+ = ASSERT( null args )
+ tcHsType ty `thenTc` \ ty' ->
+ returnTc (Con (Literal (MachLitLit lit ty')) [])
+
+-- Primops are reverse-engineered
+-- into applications of their Ids. In this way, any
+-- RULES that apply to the Id will work when this thing is unfolded.
+-- It's a bit of a hack, but it works nicely
+-- Can't do it for datacons, because the data con Id doesn't necessarily
+-- have the same type as the data con (existentials)
+
+tcUfCon (UfPrimOp name) args = tcVar name `thenTc` \ op_id ->
+ returnTc (mkApps (Var op_id) args)
+
+tcUfCon (UfDataCon name) args
+ = tcVar name `thenTc` \ con_id ->
+ case isDataConId_maybe con_id of
+ Just con -> returnTc (mkConApp con args)
+ Nothing -> failWithTc (badCon name)
+
+tcUfCon (UfCCallOp str is_dyn casm gc) args
+ | is_dyn = tcGetUnique `thenNF_Tc` \ u ->
+ returnTc (Con (PrimOp (CCallOp (Right u) casm gc cCallConv)) args)
+ | otherwise = returnTc (Con (PrimOp (CCallOp (Left str) casm gc cCallConv)) args)
+
+----------------------------------
+tcUfLit (NoRepRational lit _)
+ = -- rationalTy isn't built in so, we have to construct it
+ -- (the "ty" part of the incoming literal is simply bottom)
+ tcLookupTyConByKey rationalTyConKey `thenNF_Tc` \ rational_tycon ->
+ let
+ rational_ty = mkSynTy rational_tycon []
+ in
+ returnTc (NoRepRational lit rational_ty)
+
+-- Similarly for integers and strings, except that they are wired in
+tcUfLit (NoRepInteger lit _) = returnTc (NoRepInteger lit integerTy)
+tcUfLit (NoRepStr lit _) = returnTc (NoRepStr lit stringTy)
+tcUfLit other_lit = returnTc other_lit