X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fiface%2FBuildTyCl.lhs;h=66cb64506ce73a3c78f17232f24a14804fabfc4e;hb=6febb616f1ff46942434e9df39c6e4977b07cc6f;hp=1825ae0e3b15d073c0cb116f0c0cd2bca7865d11;hpb=5822cb8d13aa3c05d2b46b4510c13d94b902eb21;p=ghc-hetmet.git diff --git a/compiler/iface/BuildTyCl.lhs b/compiler/iface/BuildTyCl.lhs index 1825ae0..66cb645 100644 --- a/compiler/iface/BuildTyCl.lhs +++ b/compiler/iface/BuildTyCl.lhs @@ -4,6 +4,13 @@ % \begin{code} +{-# OPTIONS -w #-} +-- The above warning supression flag is a temporary kludge. +-- While working on this module you are encouraged to remove it and fix +-- any warnings in the module. See +-- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings +-- for details + module BuildTyCl ( buildSynTyCon, buildAlgTyCon, buildDataCon, buildClass, @@ -139,10 +146,9 @@ mkNewTyConRhs tycon_name tycon con ; return (NewTyCon { data_con = con, nt_rhs = rhs_ty, nt_etad_rhs = (etad_tvs, etad_rhs), - nt_co = cocon_maybe, + nt_co = cocon_maybe } ) } -- Coreview looks through newtypes with a Nothing -- for nt_co, or uses explicit coercions otherwise - nt_rep = mkNewTyConRep tycon rhs_ty }) } where -- If all_coercions is True then we use coercions for all newtypes -- otherwise we use coercions for recursive newtypes and look through @@ -173,42 +179,6 @@ mkNewTyConRhs tycon_name tycon con eta_reduce tvs ty = (reverse tvs, ty) -mkNewTyConRep :: TyCon -- The original type constructor - -> Type -- The arg type of its constructor - -> Type -- Chosen representation type --- The "representation type" is guaranteed not to be another newtype --- at the outermost level; but it might have newtypes in type arguments - --- Find the representation type for this newtype TyCon --- Remember that the representation type is the *ultimate* representation --- type, looking through other newtypes. --- --- splitTyConApp_maybe no longer looks through newtypes, so we must --- deal explicitly with this case --- --- The trick is to to deal correctly with recursive newtypes --- such as newtype T = MkT T - -mkNewTyConRep tc rhs_ty - | null (tyConDataCons tc) = unitTy - -- External Core programs can have newtypes with no data constructors - | otherwise = go [tc] rhs_ty - where - -- Invariant: tcs have been seen before - go tcs rep_ty - = case splitTyConApp_maybe rep_ty of - Just (tc, tys) - | tc `elem` tcs -> unitTy -- Recursive loop - | isNewTyCon tc -> - if isRecursiveTyCon tc then - go (tc:tcs) (substTyWith tvs tys rhs_ty) - else - substTyWith tvs tys rhs_ty - where - (tvs, rhs_ty) = newTyConRhs tc - - other -> rep_ty - ------------------------------------------------------ buildDataCon :: Name -> Bool -> [StrictnessMark] @@ -240,7 +210,7 @@ buildDataCon src_name declared_infix arg_stricts field_lbls stupid_ctxt dc_ids dc_ids = mkDataConIds wrap_name work_name data_con - ; returnM data_con } + ; return data_con } -- The stupid context for a data constructor should be limited to