diff options
author | Adam Sandberg Eriksson <adam@sandbergericsson.se> | 2015-08-10 12:55:50 +0200 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2015-08-10 13:40:21 +0200 |
commit | b4ed13000cf0cbbb5916727dad018d91c10f1fd8 (patch) | |
tree | d8d6469ff5a2f6c90042c556ed492a6cc39d0da7 /compiler/iface | |
parent | a40ec755d8e020cd4b87975f5a751f1e35c36977 (diff) | |
download | haskell-b4ed13000cf0cbbb5916727dad018d91c10f1fd8.tar.gz |
Replace HsBang type with HsSrcBang and HsImplBang
Updates haddock submodule.
Reviewers: tibbe, goldfire, simonpj, austin, bgamari
Reviewed By: simonpj, bgamari
Subscribers: goldfire, thomie, mpickering
Differential Revision: https://phabricator.haskell.org/D1069
Diffstat (limited to 'compiler/iface')
-rw-r--r-- | compiler/iface/BuildTyCl.hs | 32 | ||||
-rw-r--r-- | compiler/iface/IfaceSyn.hs | 49 | ||||
-rw-r--r-- | compiler/iface/MkIface.hs | 9 | ||||
-rw-r--r-- | compiler/iface/TcIface.hs | 30 |
4 files changed, 81 insertions, 39 deletions
diff --git a/compiler/iface/BuildTyCl.hs b/compiler/iface/BuildTyCl.hs index 28a5f68f47..0a922e86e1 100644 --- a/compiler/iface/BuildTyCl.hs +++ b/compiler/iface/BuildTyCl.hs @@ -129,20 +129,22 @@ mkNewTyConRhs tycon_name tycon con ------------------------------------------------------ buildDataCon :: FamInstEnvs -> Name -> Bool - -> [HsBang] - -> [Name] -- Field labels - -> [TyVar] -> [TyVar] -- Univ and ext - -> [(TyVar,Type)] -- Equality spec - -> ThetaType -- Does not include the "stupid theta" - -- or the GADT equalities - -> [Type] -> Type -- Argument and result types - -> TyCon -- Rep tycon - -> TcRnIf m n DataCon + -> [HsSrcBang] + -> Maybe [HsImplBang] + -- See Note [Bangs on imported data constructors] in MkId + -> [Name] -- Field labels + -> [TyVar] -> [TyVar] -- Univ and ext + -> [(TyVar,Type)] -- Equality spec + -> ThetaType -- Does not include the "stupid theta" + -- or the GADT equalities + -> [Type] -> Type -- Argument and result types + -> TyCon -- Rep tycon + -> TcRnIf m n DataCon -- A wrapper for DataCon.mkDataCon that -- a) makes the worker Id -- b) makes the wrapper Id if necessary, including -- allocating its unique (hence monadic) -buildDataCon fam_envs src_name declared_infix arg_stricts field_lbls +buildDataCon fam_envs src_name declared_infix src_bangs impl_bangs field_lbls univ_tvs ex_tvs eq_spec ctxt arg_tys res_ty rep_tycon = do { wrap_name <- newImplicitBinder src_name mkDataConWrapperOcc ; work_name <- newImplicitBinder src_name mkDataConWorkerOcc @@ -155,12 +157,13 @@ buildDataCon fam_envs src_name declared_infix arg_stricts field_lbls ; let stupid_ctxt = mkDataConStupidTheta rep_tycon arg_tys univ_tvs data_con = mkDataCon src_name declared_infix - arg_stricts field_lbls + src_bangs field_lbls univ_tvs ex_tvs eq_spec ctxt arg_tys res_ty rep_tycon stupid_ctxt dc_wrk dc_rep dc_wrk = mkDataConWorkId work_name data_con - dc_rep = initUs_ us (mkDataConRep dflags fam_envs wrap_name data_con) + dc_rep = initUs_ us (mkDataConRep dflags fam_envs wrap_name + impl_bangs data_con) ; return data_con } @@ -272,7 +275,8 @@ buildClass tycon_name tvs roles sc_theta fds at_items sig_stuff mindef tc_isrec ; dict_con <- buildDataCon (panic "buildClass: FamInstEnvs") datacon_name False -- Not declared infix - (map (const HsLazy) args) + (map (const no_bang) args) + (Just (map (const HsLazy) args)) [{- No fields -}] tvs [{- no existentials -}] [{- No GADT equalities -}] @@ -308,6 +312,8 @@ buildClass tycon_name tvs roles sc_theta fds at_items sig_stuff mindef tc_isrec ; traceIf (text "buildClass" <+> ppr tycon) ; return result } where + no_bang = HsSrcBang Nothing NoSrcUnpack NoSrcStrict + mk_op_item :: Class -> TcMethInfo -> TcRnIf n m ClassOpItem mk_op_item rec_clas (op_name, dm_spec, _) = do { dm_info <- case dm_spec of diff --git a/compiler/iface/IfaceSyn.hs b/compiler/iface/IfaceSyn.hs index 2673e111ff..fc5053b58c 100644 --- a/compiler/iface/IfaceSyn.hs +++ b/compiler/iface/IfaceSyn.hs @@ -15,7 +15,9 @@ module IfaceSyn ( IfaceIdInfo(..), IfaceIdDetails(..), IfaceUnfolding(..), IfaceInfoItem(..), IfaceRule(..), IfaceAnnotation(..), IfaceAnnTarget, IfaceClsInst(..), IfaceFamInst(..), IfaceTickish(..), - IfaceBang(..), IfaceAxBranch(..), + IfaceBang(..), + IfaceSrcBang(..), SrcUnpackedness(..), SrcStrictness(..), + IfaceAxBranch(..), IfaceTyConParent(..), -- Misc @@ -57,6 +59,7 @@ import TyCon (Role (..)) import StaticFlags (opt_PprStyle_Debug) import Util( filterOut ) import InstEnv +import DataCon (SrcStrictness(..), SrcUnpackedness(..)) import Control.Monad import System.IO.Unsafe @@ -196,20 +199,28 @@ data IfaceConDecl -- but it's not so easy for the original TyCon/DataCon -- So this guarantee holds for IfaceConDecl, but *not* for DataCon - ifConExTvs :: [IfaceTvBndr], -- Existential tyvars - ifConEqSpec :: IfaceEqSpec, -- Equality constraints - ifConCtxt :: IfaceContext, -- Non-stupid context - ifConArgTys :: [IfaceType], -- Arg types - ifConFields :: [IfaceTopBndr], -- ...ditto... (field labels) - ifConStricts :: [IfaceBang]} -- Empty (meaning all lazy), - -- or 1-1 corresp with arg tys + ifConExTvs :: [IfaceTvBndr], -- Existential tyvars + ifConEqSpec :: IfaceEqSpec, -- Equality constraints + ifConCtxt :: IfaceContext, -- Non-stupid context + ifConArgTys :: [IfaceType], -- Arg types + ifConFields :: [IfaceTopBndr], -- ...ditto... (field labels) + ifConStricts :: [IfaceBang], + -- Empty (meaning all lazy), + -- or 1-1 corresp with arg tys + -- See Note [Bangs on imported data constructors] in MkId + ifConSrcStricts :: [IfaceSrcBang] } -- empty meaning no src stricts type IfaceEqSpec = [(IfLclName,IfaceType)] -data IfaceBang -- This corresponds to an HsImplBang; that is, the final - -- implementation decision about the data constructor arg +-- | This corresponds to an HsImplBang; that is, the final +-- implementation decision about the data constructor arg +data IfaceBang = IfNoBang | IfStrict | IfUnpack | IfUnpackCo IfaceCoercion +-- | This corresponds to HsSrcBang +data IfaceSrcBang + = IfSrcBang SrcUnpackedness SrcStrictness + data IfaceClsInst = IfaceClsInst { ifInstCls :: IfExtName, -- See comments with ifInstTys :: [Maybe IfaceTyCon], -- the defn of ClsInst @@ -1506,7 +1517,7 @@ instance Binary IfaceConDecls where _ -> liftM IfNewTyCon $ get bh instance Binary IfaceConDecl where - put_ bh (IfCon a1 a2 a3 a4 a5 a6 a7 a8 a9) = do + put_ bh (IfCon a1 a2 a3 a4 a5 a6 a7 a8 a9 a10) = do put_ bh a1 put_ bh a2 put_ bh a3 @@ -1516,6 +1527,7 @@ instance Binary IfaceConDecl where put_ bh a7 put_ bh a8 put_ bh a9 + put_ bh a10 get bh = do a1 <- get bh a2 <- get bh @@ -1526,7 +1538,8 @@ instance Binary IfaceConDecl where a7 <- get bh a8 <- get bh a9 <- get bh - return (IfCon a1 a2 a3 a4 a5 a6 a7 a8 a9) + a10 <- get bh + return (IfCon a1 a2 a3 a4 a5 a6 a7 a8 a9 a10) instance Binary IfaceBang where put_ bh IfNoBang = putByte bh 0 @@ -1542,6 +1555,16 @@ instance Binary IfaceBang where 2 -> do return IfUnpack _ -> do { a <- get bh; return (IfUnpackCo a) } +instance Binary IfaceSrcBang where + put_ bh (IfSrcBang a1 a2) = + do put_ bh a1 + put_ bh a2 + + get bh = + do a1 <- get bh + a2 <- get bh + return (IfSrcBang a1 a2) + instance Binary IfaceClsInst where put_ bh (IfaceClsInst cls tys dfun flag orph) = do put_ bh cls @@ -1609,7 +1632,7 @@ instance Binary IfaceIdDetails where case h of 0 -> return IfVanillaId 1 -> do { a <- get bh; b <- get bh; return (IfRecSelId a b) } - _ -> return IfDFunId + _ -> return IfDFunId instance Binary IfaceIdInfo where put_ bh NoInfo = putByte bh 0 diff --git a/compiler/iface/MkIface.hs b/compiler/iface/MkIface.hs index 6771925094..714777adaf 100644 --- a/compiler/iface/MkIface.hs +++ b/compiler/iface/MkIface.hs @@ -1710,7 +1710,10 @@ tyConToIfaceDecl env tycon ifConArgTys = map (tidyToIfaceType con_env2) arg_tys, ifConFields = map getOccName (dataConFieldLabels data_con), - ifConStricts = map (toIfaceBang con_env2) (dataConImplBangs data_con) } + ifConStricts = map (toIfaceBang con_env2) + (dataConImplBangs data_con), + ifConSrcStricts = map toIfaceSrcBang + (dataConSrcBangs data_con)} where (univ_tvs, ex_tvs, eq_spec, theta, arg_tys, _) = dataConFullSig data_con @@ -1732,7 +1735,9 @@ toIfaceBang _ HsLazy = IfNoBang toIfaceBang _ (HsUnpack Nothing) = IfUnpack toIfaceBang env (HsUnpack (Just co)) = IfUnpackCo (toIfaceCoercion (tidyCo env co)) toIfaceBang _ HsStrict = IfStrict -toIfaceBang _ (HsSrcBang {}) = panic "toIfaceBang" + +toIfaceSrcBang :: HsSrcBang -> IfaceSrcBang +toIfaceSrcBang (HsSrcBang _ unpk bang) = IfSrcBang unpk bang classToIfaceDecl :: TidyEnv -> Class -> (TidyEnv, IfaceDecl) classToIfaceDecl env clas diff --git a/compiler/iface/TcIface.hs b/compiler/iface/TcIface.hs index 30ce0cd769..2cd256b030 100644 --- a/compiler/iface/TcIface.hs +++ b/compiler/iface/TcIface.hs @@ -515,7 +515,8 @@ tcIfaceDataCons tycon_name tycon tc_tyvars if_cons ifConExTvs = ex_tvs, ifConOcc = occ, ifConCtxt = ctxt, ifConEqSpec = spec, ifConArgTys = args, ifConFields = field_lbls, - ifConStricts = if_stricts}) + ifConStricts = if_stricts, + ifConSrcStricts = if_src_stricts}) = -- Universally-quantified tyvars are shared with -- parent TyCon, and are alrady in scope bindIfaceTyVars ex_tvs $ \ ex_tyvars -> do @@ -542,25 +543,32 @@ tcIfaceDataCons tycon_name tycon tc_tyvars if_cons (substTyVars (mkTopTvSubst eq_spec) tc_tyvars) ; con <- buildDataCon (pprPanic "tcIfaceDataCons: FamInstEnvs" (ppr name)) - name is_infix - stricts -- Pass the HsImplBangs (i.e. final decisions) - -- to buildDataCon; it'll use these to guide - -- the construction of a worker - lbl_names - tc_tyvars ex_tyvars - eq_spec theta - arg_tys orig_res_ty tycon + name is_infix + (map src_strict if_src_stricts) + (Just stricts) + -- Pass the HsImplBangs (i.e. final + -- decisions) to buildDataCon; it'll use + -- these to guide the construction of a + -- worker. + -- See Note [Bangs on imported data constructors] in MkId + lbl_names + tc_tyvars ex_tyvars + eq_spec theta + arg_tys orig_res_ty tycon ; traceIf (text "Done interface-file tc_con_decl" <+> ppr name) ; return con } mk_doc con_name = ptext (sLit "Constructor") <+> ppr con_name tc_strict :: IfaceBang -> IfL HsImplBang - tc_strict IfNoBang = return HsLazy - tc_strict IfStrict = return HsStrict + tc_strict IfNoBang = return (HsLazy) + tc_strict IfStrict = return (HsStrict) tc_strict IfUnpack = return (HsUnpack Nothing) tc_strict (IfUnpackCo if_co) = do { co <- tcIfaceCo if_co ; return (HsUnpack (Just co)) } + src_strict :: IfaceSrcBang -> HsSrcBang + src_strict (IfSrcBang unpk bang) = HsSrcBang Nothing unpk bang + tcIfaceEqSpec :: IfaceEqSpec -> IfL [(TyVar, Type)] tcIfaceEqSpec spec = mapM do_item spec |