import TcBinds ( tcPragmaSigs )
import TcClassDcl ( tcMethodBind, badMethodErr )
import TcMonad
-import RnMonad ( RnNameSupply )
+import RnMonad ( RnNameSupply, Fixities )
import Inst ( Inst, InstOrigin(..),
newDicts, LIE, emptyLIE, plusLIE, plusLIEs )
import TcDeriv ( tcDeriving )
import DataCon ( isNullaryDataCon, dataConArgTys, dataConId )
import Maybes ( maybeToBool, catMaybes, expectJust )
import MkId ( mkDictFunId )
-import Name ( nameOccName, isLocallyDefined, Module,
- NamedThing(..)
- )
+import Module ( Module )
+import Name ( nameOccName, isLocallyDefined, NamedThing(..) )
import PrelVals ( eRROR_ID )
import PprType ( pprConstraint )
import SrcLoc ( SrcLoc )
tcInstDecls1 :: ValueEnv -- Contains IdInfo for dfun ids
-> [RenamedHsDecl]
-> Module -- module name for deriving
+ -> Fixities
-> RnNameSupply -- for renaming derivings
-> TcM s (Bag InstInfo,
RenamedHsBinds)
-tcInstDecls1 unf_env decls mod_name rn_name_supply
+tcInstDecls1 unf_env decls mod_name fixs rn_name_supply
= -- Do the ordinary instance declarations
mapNF_Tc (tcInstDecl1 unf_env mod_name)
[inst_decl | InstD inst_decl <- decls] `thenNF_Tc` \ inst_info_bags ->
-- Handle "derived" instances; note that we only do derivings
-- for things in this module; we ignore deriving decls from
-- interfaces!
- tcDeriving mod_name rn_name_supply decl_inst_info
+ tcDeriving mod_name fixs rn_name_supply decl_inst_info
`thenTc` \ (deriv_inst_info, deriv_binds) ->
let
in
-- Check for respectable instance type, and context
- scrutiniseInstanceHead clas inst_tys `thenNF_Tc_`
- mapNF_Tc scrutiniseInstanceConstraint theta `thenNF_Tc_`
+ -- but only do this for non-imported instance decls.
+ -- Imported ones should have been checked already, and may indeed
+ -- contain something illegal in normal Haskell, notably
+ -- instance CCallable [Char]
+ (if isLocallyDefined dfun_name then
+ scrutiniseInstanceHead clas inst_tys `thenNF_Tc_`
+ mapNF_Tc scrutiniseInstanceConstraint theta
+ else
+ returnNF_Tc []
+ ) `thenNF_Tc_`
-- Make the dfun id and constant-method ids
let
dict_rhs
| null scs_and_meths
- = -- Blatant special case for CCallable, CReturnable [and Eval -- sof 5/98]
+ = -- Blatant special case for CCallable, CReturnable
-- If the dictionary is empty then we should never
-- select anything from it, so we make its RHS just
-- emit an error message. This in turn means that we don't