X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fiface%2FLoadIface.lhs;h=5d75259a7b802a62d719875a06512b8fc316b799;hb=49d454d8f8f0e1a83369ec12f8aafc1dcf80aea9;hp=9c89f18da90c247d5eec8dba85b6569bd8e161ee;hpb=f515d87a510f9cd3d416d83e95e6e0f0298f7d18;p=ghc-hetmet.git diff --git a/compiler/iface/LoadIface.lhs b/compiler/iface/LoadIface.lhs index 9c89f18..5d75259 100644 --- a/compiler/iface/LoadIface.lhs +++ b/compiler/iface/LoadIface.lhs @@ -323,7 +323,27 @@ loadDecl ignore_prags mod (_version, decl) ; thing <- forkM doc $ do { bumpDeclStats main_name ; tcIfaceDecl ignore_prags decl } - -- Populate the type environment with the implicitTyThings too + -- Populate the type environment with the implicitTyThings too. + -- + -- Note [Tricky iface loop] + -- ~~~~~~~~~~~~~~~~~~~~~~~~ + -- The delicate point here is that 'mini-env' should be + -- buildable from 'thing' without demanding any of the things 'forkM'd + -- by tcIfaceDecl. For example + -- class C a where { data T a; op :: T a -> Int } + -- We return the bindings + -- [("C", ), ("T", lookup env "T"), ("op", lookup env "op")] + -- The call (lookup env "T") must return the tycon T without first demanding + -- op; because getting the latter will look up T, hence loop. + -- + -- Of course, there is no reason in principle why (lookup env "T") should demand + -- anything do to with op, but take care: + -- (a) implicitTyThings, and + -- (b) getOccName of all the things returned by implicitThings, + -- must not depend on any of the nested type-checks + -- + -- All a bit too finely-balanced for my liking. + ; let mini_env = mkOccEnv [(getOccName t, t) | t <- implicitTyThings thing] lookup n = case lookupOccEnv mini_env (getOccName n) of Just thing -> thing @@ -518,7 +538,7 @@ ifaceStats eps hsep [ int (n_rules_out stats), text "rule decls imported, out of", int (n_rules_in stats), text "read"] ] -\end{code} +\end{code} %************************************************************************