X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Ftypecheck%2FTcTyDecls.lhs;h=236673163241e622688c3cf044c23d83e431cdb4;hp=11b9c3bc9599b17199aeb805736feb04b6dfeda5;hb=1e50fd4185479a62e02d987bdfcb1c62712859ca;hpb=6bc54d1524cd6d10a978bef89bc6a8f0061adb66 diff --git a/compiler/typecheck/TcTyDecls.lhs b/compiler/typecheck/TcTyDecls.lhs index 11b9c3b..2366731 100644 --- a/compiler/typecheck/TcTyDecls.lhs +++ b/compiler/typecheck/TcTyDecls.lhs @@ -31,6 +31,8 @@ import Digraph import BasicTypes import SrcLoc import Outputable +import Util ( isSingleton ) +import Data.List \end{code} @@ -102,7 +104,7 @@ synTyConsOfType ty \begin{code} calcSynCycles :: [LTyClDecl Name] -> [SCC (LTyClDecl Name)] calcSynCycles decls - = stronglyConnComp syn_edges + = stronglyConnCompFromEdgedVertices syn_edges where syn_edges = [ (ldecl, unLoc (tcdLName decl), mk_syn_edges (tcdSynRhs decl)) @@ -114,7 +116,7 @@ calcSynCycles decls calcClassCycles :: [LTyClDecl Name] -> [[LTyClDecl Name]] calcClassCycles decls - = [decls | CyclicSCC decls <- stronglyConnComp cls_edges] + = [decls | CyclicSCC decls <- stronglyConnCompFromEdgedVertices cls_edges] where cls_edges = [ (ldecl, unLoc (tcdLName decl), mk_cls_edges (unLoc (tcdCtxt decl))) @@ -232,9 +234,18 @@ calcRecFlags boot_details tyclss -- loop. We could program round this, but it'd make the code -- rather less nice, so I'm not going to do that yet. + single_con_tycons = filter (isSingleton . tyConDataCons) all_tycons + -- Both newtypes and data types, with exactly one data constructor + (new_tycons, prod_tycons) = partition isNewTyCon single_con_tycons + -- NB: we do *not* call isProductTyCon because that checks + -- for vanilla-ness of data constructors; and that depends + -- on empty existential type variables; and that is figured + -- out by tcResultType; which uses tcMatchTy; which uses + -- coreView; which calls coreExpandTyCon_maybe; which uses + -- the recursiveness of the TyCon. Result... a black hole. + -- YUK YUK YUK + --------------- Newtypes ---------------------- - new_tycons = filter isNewTyConAndNotOpen all_tycons - isNewTyConAndNotOpen tycon = isNewTyCon tycon && not (isOpenTyCon tycon) nt_loop_breakers = mkNameSet (findLoopBreakers nt_edges) is_rec_nt tc = tyConName tc `elemNameSet` nt_loop_breakers -- is_rec_nt is a locally-used helper function @@ -252,9 +263,6 @@ calcRecFlags boot_details tyclss | otherwise = [] --------------- Product types ---------------------- - -- The "prod_tycons" are the non-newtype products - prod_tycons = [tc | tc <- all_tycons, - not (isNewTyCon tc), isProductTyCon tc] prod_loop_breakers = mkNameSet (findLoopBreakers prod_edges) prod_edges = [(tc, mk_prod_edges tc) | tc <- prod_tycons] @@ -287,7 +295,7 @@ findLoopBreakers deps = go [(tc,tc,ds) | (tc,ds) <- deps] where go edges = [ name - | CyclicSCC ((tc,_,_) : edges') <- stronglyConnCompR edges, + | CyclicSCC ((tc,_,_) : edges') <- stronglyConnCompFromEdgedVerticesR edges, name <- tyConName tc : go edges'] \end{code}