X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FbasicTypes%2FDemand.lhs;h=df2758ad138b2afdfb1ea49f4f3e205245905e55;hb=bfc2cfa13fd397bb08b3267b12200c0e0763128a;hp=78b46a7e0ee19a20cd2893865285f4fe39b84b68;hpb=49c98d143c382a1341e1046f5ca00819a25691ba;p=ghc-hetmet.git diff --git a/compiler/basicTypes/Demand.lhs b/compiler/basicTypes/Demand.lhs index 78b46a7..df2758a 100644 --- a/compiler/basicTypes/Demand.lhs +++ b/compiler/basicTypes/Demand.lhs @@ -68,6 +68,9 @@ data Demand type MaybeAbsent = Bool -- True <=> not even used -- versions that don't worry about Absence: +wwLazy, wwStrict, wwPrim, wwEnum :: Demand +wwUnpack :: [Demand] -> Demand + wwLazy = WwLazy False wwStrict = WwStrict wwUnpack xs = WwUnpack False xs @@ -77,8 +80,9 @@ wwEnum = WwEnum seqDemand :: Demand -> () seqDemand (WwLazy a) = a `seq` () seqDemand (WwUnpack b ds) = b `seq` seqDemands ds -seqDemand other = () +seqDemand _ = () +seqDemands :: [Demand] -> () seqDemands [] = () seqDemands (d:ds) = seqDemand d `seq` seqDemands ds \end{code} @@ -100,7 +104,7 @@ isStrict d = not (isLazy d) isPrim :: Demand -> Bool isPrim WwPrim = True -isPrim other = False +isPrim _ = False \end{code} @@ -112,12 +116,14 @@ isPrim other = False \begin{code} +pprDemands :: [Demand] -> Bool -> SDoc pprDemands demands bot = hcat (map pprDemand demands) <> pp_bot where pp_bot | bot = ptext SLIT("B") | otherwise = empty +pprDemand :: Demand -> SDoc pprDemand (WwLazy False) = char 'L' pprDemand (WwLazy True) = char 'A' pprDemand WwStrict = char 'S' @@ -178,7 +184,7 @@ data StrictnessInfo seqStrictnessInfo :: StrictnessInfo -> () seqStrictnessInfo (StrictnessInfo ds b) = b `seq` seqDemands ds -seqStrictnessInfo other = () +seqStrictnessInfo _ = () \end{code} \begin{code} @@ -189,17 +195,21 @@ mkStrictnessInfo (xs, is_bot) | otherwise = StrictnessInfo xs is_bot where totally_boring (WwLazy False) = True - totally_boring other = False + totally_boring _ = False +noStrictnessInfo :: StrictnessInfo noStrictnessInfo = NoStrictnessInfo +isBottomingStrictness :: StrictnessInfo -> Bool isBottomingStrictness (StrictnessInfo _ bot) = bot isBottomingStrictness NoStrictnessInfo = False -- appIsBottom returns true if an application to n args would diverge +appIsBottom :: StrictnessInfo -> Int -> Bool appIsBottom (StrictnessInfo ds bot) n = bot && (listLengthCmp ds n /=GT) -- not more than 'n' elts in 'ds'. -appIsBottom NoStrictnessInfo n = False +appIsBottom NoStrictnessInfo _ = False +ppStrictnessInfo :: StrictnessInfo -> SDoc ppStrictnessInfo NoStrictnessInfo = empty ppStrictnessInfo (StrictnessInfo wrapper_args bot) = hsep [pprDemands wrapper_args bot] \end{code}