module GHC.Core.Tidy (
tidyExpr, tidyRules, tidyCbvInfoTop, tidyBndrs
) where
import GHC.Prelude
import GHC.Core
import GHC.Core.Type
import GHC.Core.Seq ( seqUnfolding )
import GHC.Types.Id
import GHC.Types.Id.Info
import GHC.Types.Demand ( zapDmdEnvSig, isStrUsedDmd )
import GHC.Core.Coercion ( tidyCo )
import GHC.Types.Var
import GHC.Types.Var.Env
import GHC.Types.Unique (getUnique)
import GHC.Types.Unique.FM
import GHC.Types.Name hiding (tidyNameOcc)
import GHC.Types.Name.Set
import GHC.Types.SrcLoc
import GHC.Types.Tickish
import GHC.Data.Maybe
import GHC.Utils.Misc
import Data.List (mapAccumL)
import GHC.Utils.Outputable
import GHC.Types.RepType (typePrimRep)
import GHC.Utils.Panic
import GHC.Types.Basic (isMarkedCbv, CbvMark (..))
import GHC.Core.Utils (shouldUseCbvForId)
tidyBind :: TidyEnv
-> CoreBind
-> (TidyEnv, CoreBind)
tidyBind :: TidyEnv -> CoreBind -> (TidyEnv, CoreBind)
tidyBind TidyEnv
env (NonRec Id
bndr Expr Id
rhs)
=
let cbv_bndr :: Id
cbv_bndr = (HasDebugCallStack => Id -> Expr Id -> Id
tidyCbvInfoLocal Id
bndr Expr Id
rhs)
(TidyEnv
env', Id
bndr') = TidyEnv -> TidyEnv -> Id -> (TidyEnv, Id)
tidyLetBndr TidyEnv
env TidyEnv
env Id
cbv_bndr
tidy_rhs :: Expr Id
tidy_rhs = (TidyEnv -> Expr Id -> Expr Id
tidyExpr TidyEnv
env' Expr Id
rhs)
in (TidyEnv
env', forall b. b -> Expr b -> Bind b
NonRec Id
bndr' Expr Id
tidy_rhs)
tidyBind TidyEnv
env (Rec [(Id, Expr Id)]
prs)
=
let
cbv_bndrs :: [Id]
cbv_bndrs = forall a b. (a -> b) -> [a] -> [b]
map ((\(Id
bnd,Expr Id
rhs) -> HasDebugCallStack => Id -> Expr Id -> Id
tidyCbvInfoLocal Id
bnd Expr Id
rhs)) [(Id, Expr Id)]
prs
([Id]
_bndrs, [Expr Id]
rhss) = forall a b. [(a, b)] -> ([a], [b])
unzip [(Id, Expr Id)]
prs
(TidyEnv
env', [Id]
bndrs') = forall (t :: * -> *) s a b.
Traversable t =>
(s -> a -> (s, b)) -> s -> t a -> (s, t b)
mapAccumL (TidyEnv -> TidyEnv -> Id -> (TidyEnv, Id)
tidyLetBndr TidyEnv
env') TidyEnv
env [Id]
cbv_bndrs
in
forall a b. (a -> b) -> [a] -> [b]
map (TidyEnv -> Expr Id -> Expr Id
tidyExpr TidyEnv
env') [Expr Id]
rhss forall a b. a -> (a -> b) -> b
=: \ [Expr Id]
rhss' ->
(TidyEnv
env', forall b. [(b, Expr b)] -> Bind b
Rec (forall a b. [a] -> [b] -> [(a, b)]
zip [Id]
bndrs' [Expr Id]
rhss'))
tidyCbvInfoTop :: HasDebugCallStack => NameSet -> Id -> CoreExpr -> Id
tidyCbvInfoTop :: HasDebugCallStack => NameSet -> Id -> Expr Id -> Id
tidyCbvInfoTop NameSet
boot_exports Id
id Expr Id
rhs
| Name -> NameSet -> Bool
elemNameSet (Id -> Name
idName Id
id) NameSet
boot_exports = Id
id
| Bool
otherwise = HasCallStack => Id -> Expr Id -> Id
computeCbvInfo Id
id Expr Id
rhs
tidyCbvInfoLocal :: HasDebugCallStack => Id -> CoreExpr -> Id
tidyCbvInfoLocal :: HasDebugCallStack => Id -> Expr Id -> Id
tidyCbvInfoLocal Id
id Expr Id
rhs = HasCallStack => Id -> Expr Id -> Id
computeCbvInfo Id
id Expr Id
rhs
computeCbvInfo :: HasCallStack
=> Id
-> CoreExpr
-> Id
computeCbvInfo :: HasCallStack => Id -> Expr Id -> Id
computeCbvInfo Id
fun_id Expr Id
rhs
| Bool
is_wkr_like Bool -> Bool -> Bool
|| forall a. Maybe a -> Bool
isJust Maybe JoinArity
mb_join_id
, forall {t :: * -> *}. Foldable t => t Id -> Bool
valid_unlifted_worker [Id]
val_args
=
Id
cbv_bndr
| Bool
otherwise = Id
fun_id
where
mb_join_id :: Maybe JoinArity
mb_join_id = Id -> Maybe JoinArity
isJoinId_maybe Id
fun_id
is_wkr_like :: Bool
is_wkr_like = Id -> Bool
isWorkerLikeId Id
fun_id
val_args :: [Id]
val_args = forall a. (a -> Bool) -> [a] -> [a]
filter Id -> Bool
isId [Id]
lam_bndrs
lam_bndrs :: [Id]
lam_bndrs | Just JoinArity
join_arity <- Maybe JoinArity
mb_join_id
= forall a b. (a, b) -> a
fst forall a b. (a -> b) -> a -> b
$ forall b. JoinArity -> Expr b -> ([b], Expr b)
collectNBinders JoinArity
join_arity Expr Id
rhs
| Bool
otherwise
= forall a b. (a, b) -> a
fst forall a b. (a -> b) -> a -> b
$ forall b. Expr b -> ([b], Expr b)
collectBinders Expr Id
rhs
cbv_marks :: [CbvMark]
cbv_marks =
forall a. HasCallStack => Bool -> SDoc -> a -> a
assertPpr (forall b a. b -> (a -> b) -> Maybe a -> b
maybe Bool
True forall (t :: * -> *) a. Foldable t => t a -> Bool
null forall a b. (a -> b) -> a -> b
$ Id -> Maybe [CbvMark]
idCbvMarks_maybe Id
fun_id)
(forall a. Outputable a => a -> SDoc
ppr Id
fun_id forall doc. IsLine doc => doc -> doc -> doc
<+> (forall a. Outputable a => a -> SDoc
ppr forall a b. (a -> b) -> a -> b
$ Id -> Maybe [CbvMark]
idCbvMarks_maybe Id
fun_id) forall doc. IsDoc doc => doc -> doc -> doc
$$ forall a. Outputable a => a -> SDoc
ppr Expr Id
rhs) forall a b. (a -> b) -> a -> b
$
forall a b. (a -> b) -> [a] -> [b]
map Id -> CbvMark
mkMark [Id]
val_args
cbv_bndr :: Id
cbv_bndr | forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any CbvMark -> Bool
isMarkedCbv [CbvMark]
cbv_marks
= [CbvMark]
cbv_marks forall a b. [a] -> b -> b
`seqList` Id -> [CbvMark] -> Id
setIdCbvMarks Id
fun_id [CbvMark]
cbv_marks
| Bool
otherwise
=
Id -> Id
asNonWorkerLikeId Id
fun_id
valid_unlifted_worker :: t Id -> Bool
valid_unlifted_worker t Id
args =
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all Id -> Bool
isSingleUnarisedArg t Id
args
isSingleUnarisedArg :: Id -> Bool
isSingleUnarisedArg Id
v
| Type -> Bool
isUnboxedSumType Type
ty = Bool
False
| Type -> Bool
isUnboxedTupleType Type
ty = forall {a}. [a] -> Bool
isSimplePrimRep (HasDebugCallStack => Type -> [PrimRep]
typePrimRep Type
ty)
| Bool
otherwise = forall {a}. [a] -> Bool
isSimplePrimRep (HasDebugCallStack => Type -> [PrimRep]
typePrimRep Type
ty)
where
ty :: Type
ty = Id -> Type
idType Id
v
isSimplePrimRep :: [a] -> Bool
isSimplePrimRep [] = Bool
True
isSimplePrimRep [a
_] = Bool
True
isSimplePrimRep [a]
_ = Bool
False
mkMark :: Id -> CbvMark
mkMark Id
arg
| Bool -> Bool
not forall a b. (a -> b) -> a -> b
$ Id -> Bool
shouldUseCbvForId Id
arg = CbvMark
NotMarkedCbv
| (Demand -> Bool
isStrUsedDmd (Id -> Demand
idDemandInfo Id
arg))
, Bool -> Bool
not (Id -> Bool
isDeadEndId Id
fun_id) = CbvMark
MarkedCbv
| Bool
otherwise = CbvMark
NotMarkedCbv
tidyExpr :: TidyEnv -> CoreExpr -> CoreExpr
tidyExpr :: TidyEnv -> Expr Id -> Expr Id
tidyExpr TidyEnv
env (Var Id
v) = forall b. Id -> Expr b
Var (TidyEnv -> Id -> Id
tidyVarOcc TidyEnv
env Id
v)
tidyExpr TidyEnv
env (Type Type
ty) = forall b. Type -> Expr b
Type (TidyEnv -> Type -> Type
tidyType TidyEnv
env Type
ty)
tidyExpr TidyEnv
env (Coercion Coercion
co) = forall b. Coercion -> Expr b
Coercion (TidyEnv -> Coercion -> Coercion
tidyCo TidyEnv
env Coercion
co)
tidyExpr TidyEnv
_ (Lit Literal
lit) = forall b. Literal -> Expr b
Lit Literal
lit
tidyExpr TidyEnv
env (App Expr Id
f Expr Id
a) = forall b. Expr b -> Expr b -> Expr b
App (TidyEnv -> Expr Id -> Expr Id
tidyExpr TidyEnv
env Expr Id
f) (TidyEnv -> Expr Id -> Expr Id
tidyExpr TidyEnv
env Expr Id
a)
tidyExpr TidyEnv
env (Tick CoreTickish
t Expr Id
e) = forall b. CoreTickish -> Expr b -> Expr b
Tick (TidyEnv -> CoreTickish -> CoreTickish
tidyTickish TidyEnv
env CoreTickish
t) (TidyEnv -> Expr Id -> Expr Id
tidyExpr TidyEnv
env Expr Id
e)
tidyExpr TidyEnv
env (Cast Expr Id
e Coercion
co) = forall b. Expr b -> Coercion -> Expr b
Cast (TidyEnv -> Expr Id -> Expr Id
tidyExpr TidyEnv
env Expr Id
e) (TidyEnv -> Coercion -> Coercion
tidyCo TidyEnv
env Coercion
co)
tidyExpr TidyEnv
env (Let CoreBind
b Expr Id
e)
= TidyEnv -> CoreBind -> (TidyEnv, CoreBind)
tidyBind TidyEnv
env CoreBind
b forall a b. a -> (a -> b) -> b
=: \ (TidyEnv
env', CoreBind
b') ->
forall b. Bind b -> Expr b -> Expr b
Let CoreBind
b' (TidyEnv -> Expr Id -> Expr Id
tidyExpr TidyEnv
env' Expr Id
e)
tidyExpr TidyEnv
env (Case Expr Id
e Id
b Type
ty [Alt Id]
alts)
= TidyEnv -> Id -> (TidyEnv, Id)
tidyBndr TidyEnv
env Id
b forall a b. a -> (a -> b) -> b
=: \ (TidyEnv
env', Id
b) ->
forall b. Expr b -> b -> Type -> [Alt b] -> Expr b
Case (TidyEnv -> Expr Id -> Expr Id
tidyExpr TidyEnv
env Expr Id
e) Id
b (TidyEnv -> Type -> Type
tidyType TidyEnv
env Type
ty)
(forall a b. (a -> b) -> [a] -> [b]
map (TidyEnv -> Alt Id -> Alt Id
tidyAlt TidyEnv
env') [Alt Id]
alts)
tidyExpr TidyEnv
env (Lam Id
b Expr Id
e)
= TidyEnv -> Id -> (TidyEnv, Id)
tidyBndr TidyEnv
env Id
b forall a b. a -> (a -> b) -> b
=: \ (TidyEnv
env', Id
b) ->
forall b. b -> Expr b -> Expr b
Lam Id
b (TidyEnv -> Expr Id -> Expr Id
tidyExpr TidyEnv
env' Expr Id
e)
tidyAlt :: TidyEnv -> CoreAlt -> CoreAlt
tidyAlt :: TidyEnv -> Alt Id -> Alt Id
tidyAlt TidyEnv
env (Alt AltCon
con [Id]
vs Expr Id
rhs)
= TidyEnv -> [Id] -> (TidyEnv, [Id])
tidyBndrs TidyEnv
env [Id]
vs forall a b. a -> (a -> b) -> b
=: \ (TidyEnv
env', [Id]
vs) ->
(forall b. AltCon -> [b] -> Expr b -> Alt b
Alt AltCon
con [Id]
vs (TidyEnv -> Expr Id -> Expr Id
tidyExpr TidyEnv
env' Expr Id
rhs))
tidyTickish :: TidyEnv -> CoreTickish -> CoreTickish
tidyTickish :: TidyEnv -> CoreTickish -> CoreTickish
tidyTickish TidyEnv
env (Breakpoint XBreakpoint 'TickishPassCore
ext JoinArity
ix [XTickishId 'TickishPassCore]
ids)
= forall (pass :: TickishPass).
XBreakpoint pass
-> JoinArity -> [XTickishId pass] -> GenTickish pass
Breakpoint XBreakpoint 'TickishPassCore
ext JoinArity
ix (forall a b. (a -> b) -> [a] -> [b]
map (TidyEnv -> Id -> Id
tidyVarOcc TidyEnv
env) [XTickishId 'TickishPassCore]
ids)
tidyTickish TidyEnv
_ CoreTickish
other_tickish = CoreTickish
other_tickish
tidyRules :: TidyEnv -> [CoreRule] -> [CoreRule]
tidyRules :: TidyEnv -> [CoreRule] -> [CoreRule]
tidyRules TidyEnv
_ [] = []
tidyRules TidyEnv
env (CoreRule
rule : [CoreRule]
rules)
= TidyEnv -> CoreRule -> CoreRule
tidyRule TidyEnv
env CoreRule
rule forall a b. a -> (a -> b) -> b
=: \ CoreRule
rule ->
TidyEnv -> [CoreRule] -> [CoreRule]
tidyRules TidyEnv
env [CoreRule]
rules forall a b. a -> (a -> b) -> b
=: \ [CoreRule]
rules ->
(CoreRule
rule forall a. a -> [a] -> [a]
: [CoreRule]
rules)
tidyRule :: TidyEnv -> CoreRule -> CoreRule
tidyRule :: TidyEnv -> CoreRule -> CoreRule
tidyRule TidyEnv
_ rule :: CoreRule
rule@(BuiltinRule {}) = CoreRule
rule
tidyRule TidyEnv
env rule :: CoreRule
rule@(Rule { ru_bndrs :: CoreRule -> [Id]
ru_bndrs = [Id]
bndrs, ru_args :: CoreRule -> [Expr Id]
ru_args = [Expr Id]
args, ru_rhs :: CoreRule -> Expr Id
ru_rhs = Expr Id
rhs,
ru_fn :: CoreRule -> Name
ru_fn = Name
fn, ru_rough :: CoreRule -> [Maybe Name]
ru_rough = [Maybe Name]
mb_ns })
= TidyEnv -> [Id] -> (TidyEnv, [Id])
tidyBndrs TidyEnv
env [Id]
bndrs forall a b. a -> (a -> b) -> b
=: \ (TidyEnv
env', [Id]
bndrs) ->
forall a b. (a -> b) -> [a] -> [b]
map (TidyEnv -> Expr Id -> Expr Id
tidyExpr TidyEnv
env') [Expr Id]
args forall a b. a -> (a -> b) -> b
=: \ [Expr Id]
args ->
CoreRule
rule { ru_bndrs :: [Id]
ru_bndrs = [Id]
bndrs, ru_args :: [Expr Id]
ru_args = [Expr Id]
args,
ru_rhs :: Expr Id
ru_rhs = TidyEnv -> Expr Id -> Expr Id
tidyExpr TidyEnv
env' Expr Id
rhs,
ru_fn :: Name
ru_fn = TidyEnv -> Name -> Name
tidyNameOcc TidyEnv
env Name
fn,
ru_rough :: [Maybe Name]
ru_rough = forall a b. (a -> b) -> [a] -> [b]
map (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (TidyEnv -> Name -> Name
tidyNameOcc TidyEnv
env')) [Maybe Name]
mb_ns }
tidyNameOcc :: TidyEnv -> Name -> Name
tidyNameOcc :: TidyEnv -> Name -> Name
tidyNameOcc (TidyOccEnv
_, VarEnv Id
var_env) Name
n = case forall key elt. UniqFM key elt -> Unique -> Maybe elt
lookupUFM_Directly VarEnv Id
var_env (forall a. Uniquable a => a -> Unique
getUnique Name
n) of
Maybe Id
Nothing -> Name
n
Just Id
v -> Id -> Name
idName Id
v
tidyVarOcc :: TidyEnv -> Var -> Var
tidyVarOcc :: TidyEnv -> Id -> Id
tidyVarOcc (TidyOccEnv
_, VarEnv Id
var_env) Id
v = forall a. VarEnv a -> Id -> Maybe a
lookupVarEnv VarEnv Id
var_env Id
v forall a. Maybe a -> a -> a
`orElse` Id
v
tidyBndr :: TidyEnv -> Var -> (TidyEnv, Var)
tidyBndr :: TidyEnv -> Id -> (TidyEnv, Id)
tidyBndr TidyEnv
env Id
var
| Id -> Bool
isTyCoVar Id
var = TidyEnv -> Id -> (TidyEnv, Id)
tidyVarBndr TidyEnv
env Id
var
| Bool
otherwise = TidyEnv -> Id -> (TidyEnv, Id)
tidyIdBndr TidyEnv
env Id
var
tidyBndrs :: TidyEnv -> [Var] -> (TidyEnv, [Var])
tidyBndrs :: TidyEnv -> [Id] -> (TidyEnv, [Id])
tidyBndrs TidyEnv
env [Id]
vars = forall (t :: * -> *) s a b.
Traversable t =>
(s -> a -> (s, b)) -> s -> t a -> (s, t b)
mapAccumL TidyEnv -> Id -> (TidyEnv, Id)
tidyBndr TidyEnv
env [Id]
vars
tidyIdBndr :: TidyEnv -> Id -> (TidyEnv, Id)
tidyIdBndr :: TidyEnv -> Id -> (TidyEnv, Id)
tidyIdBndr env :: TidyEnv
env@(TidyOccEnv
tidy_env, VarEnv Id
var_env) Id
id
=
case TidyOccEnv -> OccName -> (TidyOccEnv, OccName)
tidyOccName TidyOccEnv
tidy_env (forall a. NamedThing a => a -> OccName
getOccName Id
id) of { (TidyOccEnv
tidy_env', OccName
occ') ->
let
ty' :: Type
ty' = TidyEnv -> Type -> Type
tidyType TidyEnv
env (Id -> Type
idType Id
id)
mult' :: Type
mult' = TidyEnv -> Type -> Type
tidyType TidyEnv
env (Id -> Type
idMult Id
id)
name' :: Name
name' = Unique -> OccName -> SrcSpan -> Name
mkInternalName (Id -> Unique
idUnique Id
id) OccName
occ' SrcSpan
noSrcSpan
id' :: Id
id' = HasDebugCallStack => Name -> Type -> Type -> IdInfo -> Id
mkLocalIdWithInfo Name
name' Type
mult' Type
ty' IdInfo
new_info
var_env' :: VarEnv Id
var_env' = forall a. VarEnv a -> Id -> a -> VarEnv a
extendVarEnv VarEnv Id
var_env Id
id Id
id'
new_info :: IdInfo
new_info = IdInfo
vanillaIdInfo IdInfo -> OccInfo -> IdInfo
`setOccInfo` IdInfo -> OccInfo
occInfo IdInfo
old_info
IdInfo -> Unfolding -> IdInfo
`setUnfoldingInfo` Unfolding
new_unf
IdInfo -> OneShotInfo -> IdInfo
`setOneShotInfo` IdInfo -> OneShotInfo
oneShotInfo IdInfo
old_info
old_info :: IdInfo
old_info = HasDebugCallStack => Id -> IdInfo
idInfo Id
id
old_unf :: Unfolding
old_unf = IdInfo -> Unfolding
realUnfoldingInfo IdInfo
old_info
new_unf :: Unfolding
new_unf = Unfolding -> Unfolding
trimUnfolding Unfolding
old_unf
in
((TidyOccEnv
tidy_env', VarEnv Id
var_env'), Id
id')
}
tidyLetBndr :: TidyEnv
-> TidyEnv
-> Id -> (TidyEnv, Id)
tidyLetBndr :: TidyEnv -> TidyEnv -> Id -> (TidyEnv, Id)
tidyLetBndr TidyEnv
rec_tidy_env env :: TidyEnv
env@(TidyOccEnv
tidy_env, VarEnv Id
var_env) Id
id
= case TidyOccEnv -> OccName -> (TidyOccEnv, OccName)
tidyOccName TidyOccEnv
tidy_env (forall a. NamedThing a => a -> OccName
getOccName Id
id) of { (TidyOccEnv
tidy_env', OccName
occ') ->
let
ty' :: Type
ty' = TidyEnv -> Type -> Type
tidyType TidyEnv
env (Id -> Type
idType Id
id)
mult' :: Type
mult' = TidyEnv -> Type -> Type
tidyType TidyEnv
env (Id -> Type
idMult Id
id)
name' :: Name
name' = Unique -> OccName -> SrcSpan -> Name
mkInternalName (Id -> Unique
idUnique Id
id) OccName
occ' SrcSpan
noSrcSpan
details :: IdDetails
details = Id -> IdDetails
idDetails Id
id
id' :: Id
id' = IdDetails -> Name -> Type -> Type -> IdInfo -> Id
mkLocalVar IdDetails
details Name
name' Type
mult' Type
ty' IdInfo
new_info
var_env' :: VarEnv Id
var_env' = forall a. VarEnv a -> Id -> a -> VarEnv a
extendVarEnv VarEnv Id
var_env Id
id Id
id'
old_info :: IdInfo
old_info = HasDebugCallStack => Id -> IdInfo
idInfo Id
id
new_info :: IdInfo
new_info = IdInfo
vanillaIdInfo
IdInfo -> OccInfo -> IdInfo
`setOccInfo` IdInfo -> OccInfo
occInfo IdInfo
old_info
IdInfo -> JoinArity -> IdInfo
`setArityInfo` IdInfo -> JoinArity
arityInfo IdInfo
old_info
IdInfo -> DmdSig -> IdInfo
`setDmdSigInfo` DmdSig -> DmdSig
zapDmdEnvSig (IdInfo -> DmdSig
dmdSigInfo IdInfo
old_info)
IdInfo -> Demand -> IdInfo
`setDemandInfo` IdInfo -> Demand
demandInfo IdInfo
old_info
IdInfo -> InlinePragma -> IdInfo
`setInlinePragInfo` IdInfo -> InlinePragma
inlinePragInfo IdInfo
old_info
IdInfo -> Unfolding -> IdInfo
`setUnfoldingInfo` Unfolding
new_unf
old_unf :: Unfolding
old_unf = IdInfo -> Unfolding
realUnfoldingInfo IdInfo
old_info
new_unf :: Unfolding
new_unf = TidyEnv -> Unfolding -> Unfolding
tidyNestedUnfolding TidyEnv
rec_tidy_env Unfolding
old_unf
in
((TidyOccEnv
tidy_env', VarEnv Id
var_env'), Id
id') }
tidyNestedUnfolding :: TidyEnv -> Unfolding -> Unfolding
tidyNestedUnfolding :: TidyEnv -> Unfolding -> Unfolding
tidyNestedUnfolding TidyEnv
_ Unfolding
NoUnfolding = Unfolding
NoUnfolding
tidyNestedUnfolding TidyEnv
_ Unfolding
BootUnfolding = Unfolding
BootUnfolding
tidyNestedUnfolding TidyEnv
_ (OtherCon {}) = Unfolding
evaldUnfolding
tidyNestedUnfolding TidyEnv
tidy_env df :: Unfolding
df@(DFunUnfolding { df_bndrs :: Unfolding -> [Id]
df_bndrs = [Id]
bndrs, df_args :: Unfolding -> [Expr Id]
df_args = [Expr Id]
args })
= Unfolding
df { df_bndrs :: [Id]
df_bndrs = [Id]
bndrs', df_args :: [Expr Id]
df_args = forall a b. (a -> b) -> [a] -> [b]
map (TidyEnv -> Expr Id -> Expr Id
tidyExpr TidyEnv
tidy_env') [Expr Id]
args }
where
(TidyEnv
tidy_env', [Id]
bndrs') = TidyEnv -> [Id] -> (TidyEnv, [Id])
tidyBndrs TidyEnv
tidy_env [Id]
bndrs
tidyNestedUnfolding TidyEnv
tidy_env
unf :: Unfolding
unf@(CoreUnfolding { uf_tmpl :: Unfolding -> Expr Id
uf_tmpl = Expr Id
unf_rhs, uf_src :: Unfolding -> UnfoldingSource
uf_src = UnfoldingSource
src, uf_cache :: Unfolding -> UnfoldingCache
uf_cache = UnfoldingCache
cache })
| UnfoldingSource -> Bool
isStableSource UnfoldingSource
src
= Unfolding -> Unfolding
seqIt forall a b. (a -> b) -> a -> b
$ Unfolding
unf { uf_tmpl :: Expr Id
uf_tmpl = TidyEnv -> Expr Id -> Expr Id
tidyExpr TidyEnv
tidy_env Expr Id
unf_rhs }
| UnfoldingCache -> Bool
uf_is_value UnfoldingCache
cache = Unfolding
evaldUnfolding
| Bool
otherwise = Unfolding
noUnfolding
where
seqIt :: Unfolding -> Unfolding
seqIt Unfolding
unf = Unfolding -> ()
seqUnfolding Unfolding
unf seq :: forall a b. a -> b -> b
`seq` Unfolding
unf
(=:) :: a -> (a -> b) -> b
a
m =: :: forall a b. a -> (a -> b) -> b
=: a -> b
k = a
m seq :: forall a b. a -> b -> b
`seq` a -> b
k a
m