checkUpToDate,
- getDeclBinders
+ getDeclBinders, getDeclSysBinders
) where
#include "HsVersions.h"
import Unique ( Unique )
import StringBuffer ( StringBuffer, hGetStringBuffer )
import FastString ( mkFastString )
+import Lex
import Outputable
import IO ( isDoesNotExistError )
let
main_name = availName avail
new_decls_map = foldl add_decl decls_map
- [ (name, (version, avail, name==main_name, (mod, decl)))
+ [ (name, (version, avail, name==main_name, (mod, decl')))
| name <- sys_bndrs ++ availNames avail]
add_decl decls_map (name, stuff)
= WARN( name `elemNameEnv` decls_map, ppr name )
--
-- Here the gates are Baz and T, but *not* Foo.
let
- munged_inst_ty = case inst_ty of
- HsForAllTy tvs cxt ty -> HsForAllTy tvs [] ty
- other -> inst_ty
- free_names = extractHsTyRdrNames munged_inst_ty
+ munged_inst_ty = removeContext inst_ty
+ free_names = extractHsTyRdrNames munged_inst_ty
in
setModuleRn (moduleName mod) $
mapRn mkImportedGlobalFromRdrName free_names `thenRn` \ gate_names ->
returnRn ((mkNameSet gate_names, (mod, InstD decl)) `consBag` insts)
+
+-- In interface files, the instance decls now look like
+-- forall a. Foo a -> Baz (T a)
+-- so we have to strip off function argument types as well
+-- as the bit before the '=>' (which is always empty in interface files)
+removeContext (HsForAllTy tvs cxt ty) = HsForAllTy tvs [] (removeFuns ty)
+removeContext ty = removeFuns ty
+
+removeFuns (MonoFunTy _ ty) = removeFuns ty
+removeFuns ty = ty
+
+
loadRule :: Module -> Bag GatedDecl
-> RdrNameRuleDecl -> RnM d (Bag GatedDecl)
-- "Gate" the rule simply by whether the rule variable is
-- Nothing <=> file not found, or unreadable, or illegible
-- Just x <=> successfully found and parsed
readIface the_mod file_path
- = ioToRnM (hGetStringBuffer file_path) `thenRn` \ read_result ->
+ = ioToRnM (hGetStringBuffer False file_path) `thenRn` \ read_result ->
case read_result of
Right contents ->
- case parseIface contents (mkSrcLoc (mkFastString file_path) 1) of
- Failed err -> failWithRn Nothing err
- Succeeded (PIface mod_nm iface) ->
+ case parseIface contents
+ PState{ bol = 0#, atbol = 1#,
+ context = [],
+ glasgow_exts = 1#,
+ loc = mkSrcLoc (mkFastString file_path) 1 } of
+ PFailed err -> failWithRn Nothing err
+ POk _ (PIface mod_nm iface) ->
warnCheckRn (mod_nm == moduleName the_mod)
(hsep [ ptext SLIT("Something is amiss; requested module name")
, pprModule the_mod