{-# LANGUAGE CPP, DeriveDataTypeable, FlexibleContexts #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE BangPatterns #-}
module CoreSyn (
Expr(..), Alt, Bind(..), AltCon(..), Arg,
Tickish(..), TickishScoping(..), TickishPlacement(..),
CoreProgram, CoreExpr, CoreAlt, CoreBind, CoreArg, CoreBndr,
TaggedExpr, TaggedAlt, TaggedBind, TaggedArg, TaggedBndr(..), deTagExpr,
InId, InBind, InExpr, InAlt, InArg, InType, InKind,
InBndr, InVar, InCoercion, InTyVar, InCoVar,
OutId, OutBind, OutExpr, OutAlt, OutArg, OutType, OutKind,
OutBndr, OutVar, OutCoercion, OutTyVar, OutCoVar, MOutCoercion,
mkLet, mkLets, mkLetNonRec, mkLetRec, mkLams,
mkApps, mkTyApps, mkCoApps, mkVarApps, mkTyArg,
mkIntLit, mkIntLitInt,
mkWordLit, mkWordLitWord,
mkWord64LitWord64, mkInt64LitInt64,
mkCharLit, mkStringLit,
mkFloatLit, mkFloatLitFloat,
mkDoubleLit, mkDoubleLitDouble,
mkConApp, mkConApp2, mkTyBind, mkCoBind,
varToCoreExpr, varsToCoreExprs,
isId, cmpAltCon, cmpAlt, ltAlt,
bindersOf, bindersOfBinds, rhssOfBind, rhssOfAlts,
collectBinders, collectTyBinders, collectTyAndValBinders,
collectNBinders,
collectArgs, stripNArgs, collectArgsTicks, flattenBinds,
exprToType, exprToCoercion_maybe,
applyTypeToArg,
isValArg, isTypeArg, isCoArg, isTyCoArg, valArgCount, valBndrCount,
isRuntimeArg, isRuntimeVar,
tickishCounts, tickishScoped, tickishScopesLike, tickishFloatable,
tickishCanSplit, mkNoCount, mkNoScope,
tickishIsCode, tickishPlace,
tickishContains,
Unfolding(..), UnfoldingGuidance(..), UnfoldingSource(..),
noUnfolding, bootUnfolding, evaldUnfolding, mkOtherCon,
unSaturatedOk, needSaturated, boringCxtOk, boringCxtNotOk,
unfoldingTemplate, expandUnfolding_maybe,
maybeUnfoldingTemplate, otherCons,
isValueUnfolding, isEvaldUnfolding, isCheapUnfolding,
isExpandableUnfolding, isConLikeUnfolding, isCompulsoryUnfolding,
isStableUnfolding, isFragileUnfolding, hasSomeUnfolding,
isBootUnfolding,
canUnfold, neverUnfoldGuidance, isStableSource,
AnnExpr, AnnExpr'(..), AnnBind(..), AnnAlt,
collectAnnArgs, collectAnnArgsTicks,
deAnnotate, deAnnotate', deAnnAlt, deAnnBind,
collectAnnBndrs, collectNAnnBndrs,
IsOrphan(..), isOrphan, notOrphan, chooseOrphanAnchor,
CoreRule(..), RuleBase,
RuleName, RuleFun, IdUnfoldingFun, InScopeEnv,
RuleEnv(..), mkRuleEnv, emptyRuleEnv,
ruleArity, ruleName, ruleIdName, ruleActivation,
setRuleIdName, ruleModule,
isBuiltinRule, isLocalRule, isAutoRule,
) where
#include "HsVersions.h"
import GhcPrelude
import CostCentre
import VarEnv( InScopeSet )
import Var
import Type
import Coercion
import Name
import NameSet
import NameEnv( NameEnv, emptyNameEnv )
import Literal
import DataCon
import Module
import BasicTypes
import DynFlags
import Outputable
import Util
import UniqSet
import SrcLoc ( RealSrcSpan, containsSpan )
import Binary
import Data.Data hiding (TyCon)
import Data.Int
import Data.Word
infixl 4 `mkApps`, `mkTyApps`, `mkVarApps`, `App`, `mkCoApps`
data Expr b
= Var Id
| Lit Literal
| App (Expr b) (Arg b)
| Lam b (Expr b)
| Let (Bind b) (Expr b)
| Case (Expr b) b Type [Alt b]
| Cast (Expr b) Coercion
| Tick (Tickish Id) (Expr b)
| Type Type
| Coercion Coercion
deriving Typeable (Expr b)
DataType
Constr
Typeable (Expr b)
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Expr b -> c (Expr b))
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Expr b))
-> (Expr b -> Constr)
-> (Expr b -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Expr b)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Expr b)))
-> ((forall b. Data b => b -> b) -> Expr b -> Expr b)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Expr b -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Expr b -> r)
-> (forall u. (forall d. Data d => d -> u) -> Expr b -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Expr b -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Expr b -> m (Expr b))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Expr b -> m (Expr b))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Expr b -> m (Expr b))
-> Data (Expr b)
Expr b -> DataType
Expr b -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (Expr b))
(forall b. Data b => b -> b) -> Expr b -> Expr b
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Expr b -> c (Expr b)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Expr b)
forall b. Data b => Typeable (Expr b)
forall b. Data b => Expr b -> DataType
forall b. Data b => Expr b -> Constr
forall b.
Data b =>
(forall b. Data b => b -> b) -> Expr b -> Expr b
forall b u.
Data b =>
Int -> (forall d. Data d => d -> u) -> Expr b -> u
forall b u. Data b => (forall d. Data d => d -> u) -> Expr b -> [u]
forall b r r'.
Data b =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Expr b -> r
forall b r r'.
Data b =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Expr b -> r
forall b (m :: * -> *).
(Data b, Monad m) =>
(forall d. Data d => d -> m d) -> Expr b -> m (Expr b)
forall b (m :: * -> *).
(Data b, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Expr b -> m (Expr b)
forall b (c :: * -> *).
Data b =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Expr b)
forall b (c :: * -> *).
Data b =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Expr b -> c (Expr b)
forall b (t :: * -> *) (c :: * -> *).
(Data b, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Expr b))
forall b (t :: * -> * -> *) (c :: * -> *).
(Data b, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Expr b))
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Expr b -> u
forall u. (forall d. Data d => d -> u) -> Expr b -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Expr b -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Expr b -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Expr b -> m (Expr b)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Expr b -> m (Expr b)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Expr b)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Expr b -> c (Expr b)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Expr b))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Expr b))
$cCoercion :: Constr
$cType :: Constr
$cTick :: Constr
$cCast :: Constr
$cCase :: Constr
$cLet :: Constr
$cLam :: Constr
$cApp :: Constr
$cLit :: Constr
$cVar :: Constr
$tExpr :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Expr b -> m (Expr b)
$cgmapMo :: forall b (m :: * -> *).
(Data b, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Expr b -> m (Expr b)
gmapMp :: (forall d. Data d => d -> m d) -> Expr b -> m (Expr b)
$cgmapMp :: forall b (m :: * -> *).
(Data b, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Expr b -> m (Expr b)
gmapM :: (forall d. Data d => d -> m d) -> Expr b -> m (Expr b)
$cgmapM :: forall b (m :: * -> *).
(Data b, Monad m) =>
(forall d. Data d => d -> m d) -> Expr b -> m (Expr b)
gmapQi :: Int -> (forall d. Data d => d -> u) -> Expr b -> u
$cgmapQi :: forall b u.
Data b =>
Int -> (forall d. Data d => d -> u) -> Expr b -> u
gmapQ :: (forall d. Data d => d -> u) -> Expr b -> [u]
$cgmapQ :: forall b u. Data b => (forall d. Data d => d -> u) -> Expr b -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Expr b -> r
$cgmapQr :: forall b r r'.
Data b =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Expr b -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Expr b -> r
$cgmapQl :: forall b r r'.
Data b =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Expr b -> r
gmapT :: (forall b. Data b => b -> b) -> Expr b -> Expr b
$cgmapT :: forall b.
Data b =>
(forall b. Data b => b -> b) -> Expr b -> Expr b
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Expr b))
$cdataCast2 :: forall b (t :: * -> * -> *) (c :: * -> *).
(Data b, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Expr b))
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c (Expr b))
$cdataCast1 :: forall b (t :: * -> *) (c :: * -> *).
(Data b, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Expr b))
dataTypeOf :: Expr b -> DataType
$cdataTypeOf :: forall b. Data b => Expr b -> DataType
toConstr :: Expr b -> Constr
$ctoConstr :: forall b. Data b => Expr b -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Expr b)
$cgunfold :: forall b (c :: * -> *).
Data b =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Expr b)
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Expr b -> c (Expr b)
$cgfoldl :: forall b (c :: * -> *).
Data b =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Expr b -> c (Expr b)
$cp1Data :: forall b. Data b => Typeable (Expr b)
Data
type Arg b = Expr b
type Alt b = (AltCon, [b], Expr b)
data AltCon
= DataAlt DataCon
| LitAlt Literal
| DEFAULT
deriving (AltCon -> AltCon -> Bool
(AltCon -> AltCon -> Bool)
-> (AltCon -> AltCon -> Bool) -> Eq AltCon
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AltCon -> AltCon -> Bool
$c/= :: AltCon -> AltCon -> Bool
== :: AltCon -> AltCon -> Bool
$c== :: AltCon -> AltCon -> Bool
Eq, Typeable AltCon
DataType
Constr
Typeable AltCon
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AltCon -> c AltCon)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AltCon)
-> (AltCon -> Constr)
-> (AltCon -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AltCon))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AltCon))
-> ((forall b. Data b => b -> b) -> AltCon -> AltCon)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> AltCon -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> AltCon -> r)
-> (forall u. (forall d. Data d => d -> u) -> AltCon -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> AltCon -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AltCon -> m AltCon)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AltCon -> m AltCon)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AltCon -> m AltCon)
-> Data AltCon
AltCon -> DataType
AltCon -> Constr
(forall b. Data b => b -> b) -> AltCon -> AltCon
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AltCon -> c AltCon
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AltCon
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> AltCon -> u
forall u. (forall d. Data d => d -> u) -> AltCon -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> AltCon -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> AltCon -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AltCon -> m AltCon
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AltCon -> m AltCon
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AltCon
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AltCon -> c AltCon
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AltCon)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AltCon)
$cDEFAULT :: Constr
$cLitAlt :: Constr
$cDataAlt :: Constr
$tAltCon :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> AltCon -> m AltCon
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AltCon -> m AltCon
gmapMp :: (forall d. Data d => d -> m d) -> AltCon -> m AltCon
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> AltCon -> m AltCon
gmapM :: (forall d. Data d => d -> m d) -> AltCon -> m AltCon
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> AltCon -> m AltCon
gmapQi :: Int -> (forall d. Data d => d -> u) -> AltCon -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> AltCon -> u
gmapQ :: (forall d. Data d => d -> u) -> AltCon -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> AltCon -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> AltCon -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> AltCon -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> AltCon -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> AltCon -> r
gmapT :: (forall b. Data b => b -> b) -> AltCon -> AltCon
$cgmapT :: (forall b. Data b => b -> b) -> AltCon -> AltCon
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AltCon)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c AltCon)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c AltCon)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c AltCon)
dataTypeOf :: AltCon -> DataType
$cdataTypeOf :: AltCon -> DataType
toConstr :: AltCon -> Constr
$ctoConstr :: AltCon -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AltCon
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c AltCon
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AltCon -> c AltCon
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> AltCon -> c AltCon
$cp1Data :: Typeable AltCon
Data)
instance Ord AltCon where
compare :: AltCon -> AltCon -> Ordering
compare (DataAlt DataCon
con1) (DataAlt DataCon
con2) =
ASSERT( dataConTyCon con1 == dataConTyCon con2 )
Int -> Int -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (DataCon -> Int
dataConTag DataCon
con1) (DataCon -> Int
dataConTag DataCon
con2)
compare (DataAlt DataCon
_) AltCon
_ = Ordering
GT
compare AltCon
_ (DataAlt DataCon
_) = Ordering
LT
compare (LitAlt Literal
l1) (LitAlt Literal
l2) = Literal -> Literal -> Ordering
forall a. Ord a => a -> a -> Ordering
compare Literal
l1 Literal
l2
compare (LitAlt Literal
_) AltCon
DEFAULT = Ordering
GT
compare AltCon
DEFAULT AltCon
DEFAULT = Ordering
EQ
compare AltCon
DEFAULT AltCon
_ = Ordering
LT
data Bind b = NonRec b (Expr b)
| Rec [(b, (Expr b))]
deriving Typeable (Bind b)
DataType
Constr
Typeable (Bind b)
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Bind b -> c (Bind b))
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Bind b))
-> (Bind b -> Constr)
-> (Bind b -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Bind b)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Bind b)))
-> ((forall b. Data b => b -> b) -> Bind b -> Bind b)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Bind b -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Bind b -> r)
-> (forall u. (forall d. Data d => d -> u) -> Bind b -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Bind b -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Bind b -> m (Bind b))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Bind b -> m (Bind b))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Bind b -> m (Bind b))
-> Data (Bind b)
Bind b -> DataType
Bind b -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (Bind b))
(forall b. Data b => b -> b) -> Bind b -> Bind b
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Bind b -> c (Bind b)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Bind b)
forall b. Data b => Typeable (Bind b)
forall b. Data b => Bind b -> DataType
forall b. Data b => Bind b -> Constr
forall b.
Data b =>
(forall b. Data b => b -> b) -> Bind b -> Bind b
forall b u.
Data b =>
Int -> (forall d. Data d => d -> u) -> Bind b -> u
forall b u. Data b => (forall d. Data d => d -> u) -> Bind b -> [u]
forall b r r'.
Data b =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Bind b -> r
forall b r r'.
Data b =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Bind b -> r
forall b (m :: * -> *).
(Data b, Monad m) =>
(forall d. Data d => d -> m d) -> Bind b -> m (Bind b)
forall b (m :: * -> *).
(Data b, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Bind b -> m (Bind b)
forall b (c :: * -> *).
Data b =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Bind b)
forall b (c :: * -> *).
Data b =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Bind b -> c (Bind b)
forall b (t :: * -> *) (c :: * -> *).
(Data b, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Bind b))
forall b (t :: * -> * -> *) (c :: * -> *).
(Data b, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Bind b))
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Bind b -> u
forall u. (forall d. Data d => d -> u) -> Bind b -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Bind b -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Bind b -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Bind b -> m (Bind b)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Bind b -> m (Bind b)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Bind b)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Bind b -> c (Bind b)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Bind b))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Bind b))
$cRec :: Constr
$cNonRec :: Constr
$tBind :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Bind b -> m (Bind b)
$cgmapMo :: forall b (m :: * -> *).
(Data b, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Bind b -> m (Bind b)
gmapMp :: (forall d. Data d => d -> m d) -> Bind b -> m (Bind b)
$cgmapMp :: forall b (m :: * -> *).
(Data b, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Bind b -> m (Bind b)
gmapM :: (forall d. Data d => d -> m d) -> Bind b -> m (Bind b)
$cgmapM :: forall b (m :: * -> *).
(Data b, Monad m) =>
(forall d. Data d => d -> m d) -> Bind b -> m (Bind b)
gmapQi :: Int -> (forall d. Data d => d -> u) -> Bind b -> u
$cgmapQi :: forall b u.
Data b =>
Int -> (forall d. Data d => d -> u) -> Bind b -> u
gmapQ :: (forall d. Data d => d -> u) -> Bind b -> [u]
$cgmapQ :: forall b u. Data b => (forall d. Data d => d -> u) -> Bind b -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Bind b -> r
$cgmapQr :: forall b r r'.
Data b =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Bind b -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Bind b -> r
$cgmapQl :: forall b r r'.
Data b =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Bind b -> r
gmapT :: (forall b. Data b => b -> b) -> Bind b -> Bind b
$cgmapT :: forall b.
Data b =>
(forall b. Data b => b -> b) -> Bind b -> Bind b
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Bind b))
$cdataCast2 :: forall b (t :: * -> * -> *) (c :: * -> *).
(Data b, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Bind b))
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c (Bind b))
$cdataCast1 :: forall b (t :: * -> *) (c :: * -> *).
(Data b, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Bind b))
dataTypeOf :: Bind b -> DataType
$cdataTypeOf :: forall b. Data b => Bind b -> DataType
toConstr :: Bind b -> Constr
$ctoConstr :: forall b. Data b => Bind b -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Bind b)
$cgunfold :: forall b (c :: * -> *).
Data b =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Bind b)
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Bind b -> c (Bind b)
$cgfoldl :: forall b (c :: * -> *).
Data b =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Bind b -> c (Bind b)
$cp1Data :: forall b. Data b => Typeable (Bind b)
Data
type InBndr = CoreBndr
type InType = Type
type InKind = Kind
type InBind = CoreBind
type InExpr = CoreExpr
type InAlt = CoreAlt
type InArg = CoreArg
type InCoercion = Coercion
type OutBndr = CoreBndr
type OutType = Type
type OutKind = Kind
type OutCoercion = Coercion
type OutBind = CoreBind
type OutExpr = CoreExpr
type OutAlt = CoreAlt
type OutArg = CoreArg
type MOutCoercion = MCoercion
data Tickish id =
ProfNote {
Tickish id -> CostCentre
profNoteCC :: CostCentre,
Tickish id -> Bool
profNoteCount :: !Bool,
Tickish id -> Bool
profNoteScope :: !Bool
}
| HpcTick {
Tickish id -> Module
tickModule :: Module,
Tickish id -> Int
tickId :: !Int
}
| Breakpoint
{ Tickish id -> Int
breakpointId :: !Int
, Tickish id -> [id]
breakpointFVs :: [id]
}
| SourceNote
{ Tickish id -> RealSrcSpan
sourceSpan :: RealSrcSpan
, Tickish id -> String
sourceName :: String
}
deriving (Tickish id -> Tickish id -> Bool
(Tickish id -> Tickish id -> Bool)
-> (Tickish id -> Tickish id -> Bool) -> Eq (Tickish id)
forall id. Eq id => Tickish id -> Tickish id -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Tickish id -> Tickish id -> Bool
$c/= :: forall id. Eq id => Tickish id -> Tickish id -> Bool
== :: Tickish id -> Tickish id -> Bool
$c== :: forall id. Eq id => Tickish id -> Tickish id -> Bool
Eq, Eq (Tickish id)
Eq (Tickish id)
-> (Tickish id -> Tickish id -> Ordering)
-> (Tickish id -> Tickish id -> Bool)
-> (Tickish id -> Tickish id -> Bool)
-> (Tickish id -> Tickish id -> Bool)
-> (Tickish id -> Tickish id -> Bool)
-> (Tickish id -> Tickish id -> Tickish id)
-> (Tickish id -> Tickish id -> Tickish id)
-> Ord (Tickish id)
Tickish id -> Tickish id -> Bool
Tickish id -> Tickish id -> Ordering
Tickish id -> Tickish id -> Tickish id
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall id. Ord id => Eq (Tickish id)
forall id. Ord id => Tickish id -> Tickish id -> Bool
forall id. Ord id => Tickish id -> Tickish id -> Ordering
forall id. Ord id => Tickish id -> Tickish id -> Tickish id
min :: Tickish id -> Tickish id -> Tickish id
$cmin :: forall id. Ord id => Tickish id -> Tickish id -> Tickish id
max :: Tickish id -> Tickish id -> Tickish id
$cmax :: forall id. Ord id => Tickish id -> Tickish id -> Tickish id
>= :: Tickish id -> Tickish id -> Bool
$c>= :: forall id. Ord id => Tickish id -> Tickish id -> Bool
> :: Tickish id -> Tickish id -> Bool
$c> :: forall id. Ord id => Tickish id -> Tickish id -> Bool
<= :: Tickish id -> Tickish id -> Bool
$c<= :: forall id. Ord id => Tickish id -> Tickish id -> Bool
< :: Tickish id -> Tickish id -> Bool
$c< :: forall id. Ord id => Tickish id -> Tickish id -> Bool
compare :: Tickish id -> Tickish id -> Ordering
$ccompare :: forall id. Ord id => Tickish id -> Tickish id -> Ordering
$cp1Ord :: forall id. Ord id => Eq (Tickish id)
Ord, Typeable (Tickish id)
DataType
Constr
Typeable (Tickish id)
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Tickish id -> c (Tickish id))
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Tickish id))
-> (Tickish id -> Constr)
-> (Tickish id -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Tickish id)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Tickish id)))
-> ((forall b. Data b => b -> b) -> Tickish id -> Tickish id)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Tickish id -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Tickish id -> r)
-> (forall u. (forall d. Data d => d -> u) -> Tickish id -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> Tickish id -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Tickish id -> m (Tickish id))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Tickish id -> m (Tickish id))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Tickish id -> m (Tickish id))
-> Data (Tickish id)
Tickish id -> DataType
Tickish id -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (Tickish id))
(forall b. Data b => b -> b) -> Tickish id -> Tickish id
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Tickish id -> c (Tickish id)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Tickish id)
forall id. Data id => Typeable (Tickish id)
forall id. Data id => Tickish id -> DataType
forall id. Data id => Tickish id -> Constr
forall id.
Data id =>
(forall b. Data b => b -> b) -> Tickish id -> Tickish id
forall id u.
Data id =>
Int -> (forall d. Data d => d -> u) -> Tickish id -> u
forall id u.
Data id =>
(forall d. Data d => d -> u) -> Tickish id -> [u]
forall id r r'.
Data id =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Tickish id -> r
forall id r r'.
Data id =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Tickish id -> r
forall id (m :: * -> *).
(Data id, Monad m) =>
(forall d. Data d => d -> m d) -> Tickish id -> m (Tickish id)
forall id (m :: * -> *).
(Data id, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Tickish id -> m (Tickish id)
forall id (c :: * -> *).
Data id =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Tickish id)
forall id (c :: * -> *).
Data id =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Tickish id -> c (Tickish id)
forall id (t :: * -> *) (c :: * -> *).
(Data id, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Tickish id))
forall id (t :: * -> * -> *) (c :: * -> *).
(Data id, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Tickish id))
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Tickish id -> u
forall u. (forall d. Data d => d -> u) -> Tickish id -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Tickish id -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Tickish id -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Tickish id -> m (Tickish id)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Tickish id -> m (Tickish id)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Tickish id)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Tickish id -> c (Tickish id)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Tickish id))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Tickish id))
$cSourceNote :: Constr
$cBreakpoint :: Constr
$cHpcTick :: Constr
$cProfNote :: Constr
$tTickish :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Tickish id -> m (Tickish id)
$cgmapMo :: forall id (m :: * -> *).
(Data id, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Tickish id -> m (Tickish id)
gmapMp :: (forall d. Data d => d -> m d) -> Tickish id -> m (Tickish id)
$cgmapMp :: forall id (m :: * -> *).
(Data id, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Tickish id -> m (Tickish id)
gmapM :: (forall d. Data d => d -> m d) -> Tickish id -> m (Tickish id)
$cgmapM :: forall id (m :: * -> *).
(Data id, Monad m) =>
(forall d. Data d => d -> m d) -> Tickish id -> m (Tickish id)
gmapQi :: Int -> (forall d. Data d => d -> u) -> Tickish id -> u
$cgmapQi :: forall id u.
Data id =>
Int -> (forall d. Data d => d -> u) -> Tickish id -> u
gmapQ :: (forall d. Data d => d -> u) -> Tickish id -> [u]
$cgmapQ :: forall id u.
Data id =>
(forall d. Data d => d -> u) -> Tickish id -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Tickish id -> r
$cgmapQr :: forall id r r'.
Data id =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Tickish id -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Tickish id -> r
$cgmapQl :: forall id r r'.
Data id =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Tickish id -> r
gmapT :: (forall b. Data b => b -> b) -> Tickish id -> Tickish id
$cgmapT :: forall id.
Data id =>
(forall b. Data b => b -> b) -> Tickish id -> Tickish id
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Tickish id))
$cdataCast2 :: forall id (t :: * -> * -> *) (c :: * -> *).
(Data id, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Tickish id))
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c (Tickish id))
$cdataCast1 :: forall id (t :: * -> *) (c :: * -> *).
(Data id, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Tickish id))
dataTypeOf :: Tickish id -> DataType
$cdataTypeOf :: forall id. Data id => Tickish id -> DataType
toConstr :: Tickish id -> Constr
$ctoConstr :: forall id. Data id => Tickish id -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Tickish id)
$cgunfold :: forall id (c :: * -> *).
Data id =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Tickish id)
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Tickish id -> c (Tickish id)
$cgfoldl :: forall id (c :: * -> *).
Data id =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Tickish id -> c (Tickish id)
$cp1Data :: forall id. Data id => Typeable (Tickish id)
Data)
tickishCounts :: Tickish id -> Bool
tickishCounts :: Tickish id -> Bool
tickishCounts n :: Tickish id
n@ProfNote{} = Tickish id -> Bool
forall id. Tickish id -> Bool
profNoteCount Tickish id
n
tickishCounts HpcTick{} = Bool
True
tickishCounts Breakpoint{} = Bool
True
tickishCounts Tickish id
_ = Bool
False
data TickishScoping =
NoScope
| SoftScope
| CostCentreScope
deriving (TickishScoping -> TickishScoping -> Bool
(TickishScoping -> TickishScoping -> Bool)
-> (TickishScoping -> TickishScoping -> Bool) -> Eq TickishScoping
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TickishScoping -> TickishScoping -> Bool
$c/= :: TickishScoping -> TickishScoping -> Bool
== :: TickishScoping -> TickishScoping -> Bool
$c== :: TickishScoping -> TickishScoping -> Bool
Eq)
tickishScoped :: Tickish id -> TickishScoping
tickishScoped :: Tickish id -> TickishScoping
tickishScoped n :: Tickish id
n@ProfNote{}
| Tickish id -> Bool
forall id. Tickish id -> Bool
profNoteScope Tickish id
n = TickishScoping
CostCentreScope
| Bool
otherwise = TickishScoping
NoScope
tickishScoped HpcTick{} = TickishScoping
NoScope
tickishScoped Breakpoint{} = TickishScoping
CostCentreScope
tickishScoped SourceNote{} = TickishScoping
SoftScope
tickishScopesLike :: Tickish id -> TickishScoping -> Bool
tickishScopesLike :: Tickish id -> TickishScoping -> Bool
tickishScopesLike Tickish id
t TickishScoping
scope = Tickish id -> TickishScoping
forall id. Tickish id -> TickishScoping
tickishScoped Tickish id
t TickishScoping -> TickishScoping -> Bool
`like` TickishScoping
scope
where TickishScoping
NoScope like :: TickishScoping -> TickishScoping -> Bool
`like` TickishScoping
_ = Bool
True
TickishScoping
_ `like` TickishScoping
NoScope = Bool
False
TickishScoping
SoftScope `like` TickishScoping
_ = Bool
True
TickishScoping
_ `like` TickishScoping
SoftScope = Bool
False
TickishScoping
CostCentreScope `like` TickishScoping
_ = Bool
True
tickishFloatable :: Tickish id -> Bool
tickishFloatable :: Tickish id -> Bool
tickishFloatable Tickish id
t = Tickish id
t Tickish id -> TickishScoping -> Bool
forall id. Tickish id -> TickishScoping -> Bool
`tickishScopesLike` TickishScoping
SoftScope Bool -> Bool -> Bool
&& Bool -> Bool
not (Tickish id -> Bool
forall id. Tickish id -> Bool
tickishCounts Tickish id
t)
tickishCanSplit :: Tickish id -> Bool
tickishCanSplit :: Tickish id -> Bool
tickishCanSplit ProfNote{profNoteScope :: forall id. Tickish id -> Bool
profNoteScope = Bool
True, profNoteCount :: forall id. Tickish id -> Bool
profNoteCount = Bool
True}
= Bool
True
tickishCanSplit Tickish id
_ = Bool
False
mkNoCount :: Tickish id -> Tickish id
mkNoCount :: Tickish id -> Tickish id
mkNoCount Tickish id
n | Bool -> Bool
not (Tickish id -> Bool
forall id. Tickish id -> Bool
tickishCounts Tickish id
n) = Tickish id
n
| Bool -> Bool
not (Tickish id -> Bool
forall id. Tickish id -> Bool
tickishCanSplit Tickish id
n) = String -> Tickish id
forall a. String -> a
panic String
"mkNoCount: Cannot split!"
mkNoCount n :: Tickish id
n@ProfNote{} = Tickish id
n {profNoteCount :: Bool
profNoteCount = Bool
False}
mkNoCount Tickish id
_ = String -> Tickish id
forall a. String -> a
panic String
"mkNoCount: Undefined split!"
mkNoScope :: Tickish id -> Tickish id
mkNoScope :: Tickish id -> Tickish id
mkNoScope Tickish id
n | Tickish id -> TickishScoping
forall id. Tickish id -> TickishScoping
tickishScoped Tickish id
n TickishScoping -> TickishScoping -> Bool
forall a. Eq a => a -> a -> Bool
== TickishScoping
NoScope = Tickish id
n
| Bool -> Bool
not (Tickish id -> Bool
forall id. Tickish id -> Bool
tickishCanSplit Tickish id
n) = String -> Tickish id
forall a. String -> a
panic String
"mkNoScope: Cannot split!"
mkNoScope n :: Tickish id
n@ProfNote{} = Tickish id
n {profNoteScope :: Bool
profNoteScope = Bool
False}
mkNoScope Tickish id
_ = String -> Tickish id
forall a. String -> a
panic String
"mkNoScope: Undefined split!"
tickishIsCode :: Tickish id -> Bool
tickishIsCode :: Tickish id -> Bool
tickishIsCode SourceNote{} = Bool
False
tickishIsCode Tickish id
_tickish = Bool
True
data TickishPlacement =
PlaceRuntime
| PlaceNonLam
| PlaceCostCentre
deriving (TickishPlacement -> TickishPlacement -> Bool
(TickishPlacement -> TickishPlacement -> Bool)
-> (TickishPlacement -> TickishPlacement -> Bool)
-> Eq TickishPlacement
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TickishPlacement -> TickishPlacement -> Bool
$c/= :: TickishPlacement -> TickishPlacement -> Bool
== :: TickishPlacement -> TickishPlacement -> Bool
$c== :: TickishPlacement -> TickishPlacement -> Bool
Eq)
tickishPlace :: Tickish id -> TickishPlacement
tickishPlace :: Tickish id -> TickishPlacement
tickishPlace n :: Tickish id
n@ProfNote{}
| Tickish id -> Bool
forall id. Tickish id -> Bool
profNoteCount Tickish id
n = TickishPlacement
PlaceRuntime
| Bool
otherwise = TickishPlacement
PlaceCostCentre
tickishPlace HpcTick{} = TickishPlacement
PlaceRuntime
tickishPlace Breakpoint{} = TickishPlacement
PlaceRuntime
tickishPlace SourceNote{} = TickishPlacement
PlaceNonLam
tickishContains :: Eq b => Tickish b -> Tickish b -> Bool
tickishContains :: Tickish b -> Tickish b -> Bool
tickishContains (SourceNote RealSrcSpan
sp1 String
n1) (SourceNote RealSrcSpan
sp2 String
n2)
= RealSrcSpan -> RealSrcSpan -> Bool
containsSpan RealSrcSpan
sp1 RealSrcSpan
sp2 Bool -> Bool -> Bool
&& String
n1 String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== String
n2
tickishContains Tickish b
t1 Tickish b
t2
= Tickish b
t1 Tickish b -> Tickish b -> Bool
forall a. Eq a => a -> a -> Bool
== Tickish b
t2
data IsOrphan
= IsOrphan
| NotOrphan OccName
deriving Typeable IsOrphan
DataType
Constr
Typeable IsOrphan
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> IsOrphan -> c IsOrphan)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c IsOrphan)
-> (IsOrphan -> Constr)
-> (IsOrphan -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c IsOrphan))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c IsOrphan))
-> ((forall b. Data b => b -> b) -> IsOrphan -> IsOrphan)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> IsOrphan -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> IsOrphan -> r)
-> (forall u. (forall d. Data d => d -> u) -> IsOrphan -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> IsOrphan -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> IsOrphan -> m IsOrphan)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> IsOrphan -> m IsOrphan)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> IsOrphan -> m IsOrphan)
-> Data IsOrphan
IsOrphan -> DataType
IsOrphan -> Constr
(forall b. Data b => b -> b) -> IsOrphan -> IsOrphan
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> IsOrphan -> c IsOrphan
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c IsOrphan
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> IsOrphan -> u
forall u. (forall d. Data d => d -> u) -> IsOrphan -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> IsOrphan -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> IsOrphan -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> IsOrphan -> m IsOrphan
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> IsOrphan -> m IsOrphan
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c IsOrphan
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> IsOrphan -> c IsOrphan
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c IsOrphan)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c IsOrphan)
$cNotOrphan :: Constr
$cIsOrphan :: Constr
$tIsOrphan :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> IsOrphan -> m IsOrphan
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> IsOrphan -> m IsOrphan
gmapMp :: (forall d. Data d => d -> m d) -> IsOrphan -> m IsOrphan
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> IsOrphan -> m IsOrphan
gmapM :: (forall d. Data d => d -> m d) -> IsOrphan -> m IsOrphan
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> IsOrphan -> m IsOrphan
gmapQi :: Int -> (forall d. Data d => d -> u) -> IsOrphan -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> IsOrphan -> u
gmapQ :: (forall d. Data d => d -> u) -> IsOrphan -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> IsOrphan -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> IsOrphan -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> IsOrphan -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> IsOrphan -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> IsOrphan -> r
gmapT :: (forall b. Data b => b -> b) -> IsOrphan -> IsOrphan
$cgmapT :: (forall b. Data b => b -> b) -> IsOrphan -> IsOrphan
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c IsOrphan)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c IsOrphan)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c IsOrphan)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c IsOrphan)
dataTypeOf :: IsOrphan -> DataType
$cdataTypeOf :: IsOrphan -> DataType
toConstr :: IsOrphan -> Constr
$ctoConstr :: IsOrphan -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c IsOrphan
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c IsOrphan
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> IsOrphan -> c IsOrphan
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> IsOrphan -> c IsOrphan
$cp1Data :: Typeable IsOrphan
Data
isOrphan :: IsOrphan -> Bool
isOrphan :: IsOrphan -> Bool
isOrphan IsOrphan
IsOrphan = Bool
True
isOrphan IsOrphan
_ = Bool
False
notOrphan :: IsOrphan -> Bool
notOrphan :: IsOrphan -> Bool
notOrphan NotOrphan{} = Bool
True
notOrphan IsOrphan
_ = Bool
False
chooseOrphanAnchor :: NameSet -> IsOrphan
chooseOrphanAnchor :: NameSet -> IsOrphan
chooseOrphanAnchor NameSet
local_names
| NameSet -> Bool
isEmptyNameSet NameSet
local_names = IsOrphan
IsOrphan
| Bool
otherwise = OccName -> IsOrphan
NotOrphan ([OccName] -> OccName
forall (t :: * -> *) a. (Foldable t, Ord a) => t a -> a
minimum [OccName]
occs)
where
occs :: [OccName]
occs = (Name -> OccName) -> [Name] -> [OccName]
forall a b. (a -> b) -> [a] -> [b]
map Name -> OccName
nameOccName ([Name] -> [OccName]) -> [Name] -> [OccName]
forall a b. (a -> b) -> a -> b
$ NameSet -> [Name]
forall elt. UniqSet elt -> [elt]
nonDetEltsUniqSet NameSet
local_names
instance Binary IsOrphan where
put_ :: BinHandle -> IsOrphan -> IO ()
put_ BinHandle
bh IsOrphan
IsOrphan = BinHandle -> Word8 -> IO ()
putByte BinHandle
bh Word8
0
put_ BinHandle
bh (NotOrphan OccName
n) = do
BinHandle -> Word8 -> IO ()
putByte BinHandle
bh Word8
1
BinHandle -> OccName -> IO ()
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh OccName
n
get :: BinHandle -> IO IsOrphan
get BinHandle
bh = do
Word8
h <- BinHandle -> IO Word8
getByte BinHandle
bh
case Word8
h of
Word8
0 -> IsOrphan -> IO IsOrphan
forall (m :: * -> *) a. Monad m => a -> m a
return IsOrphan
IsOrphan
Word8
_ -> do
OccName
n <- BinHandle -> IO OccName
forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
IsOrphan -> IO IsOrphan
forall (m :: * -> *) a. Monad m => a -> m a
return (IsOrphan -> IO IsOrphan) -> IsOrphan -> IO IsOrphan
forall a b. (a -> b) -> a -> b
$ OccName -> IsOrphan
NotOrphan OccName
n
type RuleBase = NameEnv [CoreRule]
data RuleEnv
= RuleEnv { RuleEnv -> RuleBase
re_base :: RuleBase
, RuleEnv -> ModuleSet
re_visible_orphs :: ModuleSet
}
mkRuleEnv :: RuleBase -> [Module] -> RuleEnv
mkRuleEnv :: RuleBase -> [Module] -> RuleEnv
mkRuleEnv RuleBase
rules [Module]
vis_orphs = RuleBase -> ModuleSet -> RuleEnv
RuleEnv RuleBase
rules ([Module] -> ModuleSet
mkModuleSet [Module]
vis_orphs)
emptyRuleEnv :: RuleEnv
emptyRuleEnv :: RuleEnv
emptyRuleEnv = RuleBase -> ModuleSet -> RuleEnv
RuleEnv RuleBase
forall a. NameEnv a
emptyNameEnv ModuleSet
emptyModuleSet
data CoreRule
= Rule {
CoreRule -> RuleName
ru_name :: RuleName,
CoreRule -> Activation
ru_act :: Activation,
CoreRule -> Name
ru_fn :: Name,
CoreRule -> [Maybe Name]
ru_rough :: [Maybe Name],
CoreRule -> [CoreBndr]
ru_bndrs :: [CoreBndr],
CoreRule -> [CoreExpr]
ru_args :: [CoreExpr],
CoreRule -> CoreExpr
ru_rhs :: CoreExpr,
CoreRule -> Bool
ru_auto :: Bool,
CoreRule -> Module
ru_origin :: !Module,
CoreRule -> IsOrphan
ru_orphan :: !IsOrphan,
CoreRule -> Bool
ru_local :: Bool
}
| BuiltinRule {
ru_name :: RuleName,
ru_fn :: Name,
CoreRule -> Int
ru_nargs :: Int,
CoreRule -> RuleFun
ru_try :: RuleFun
}
type RuleFun = DynFlags -> InScopeEnv -> Id -> [CoreExpr] -> Maybe CoreExpr
type InScopeEnv = (InScopeSet, IdUnfoldingFun)
type IdUnfoldingFun = Id -> Unfolding
isBuiltinRule :: CoreRule -> Bool
isBuiltinRule :: CoreRule -> Bool
isBuiltinRule (BuiltinRule {}) = Bool
True
isBuiltinRule CoreRule
_ = Bool
False
isAutoRule :: CoreRule -> Bool
isAutoRule :: CoreRule -> Bool
isAutoRule (BuiltinRule {}) = Bool
False
isAutoRule (Rule { ru_auto :: CoreRule -> Bool
ru_auto = Bool
is_auto }) = Bool
is_auto
ruleArity :: CoreRule -> Int
ruleArity :: CoreRule -> Int
ruleArity (BuiltinRule {ru_nargs :: CoreRule -> Int
ru_nargs = Int
n}) = Int
n
ruleArity (Rule {ru_args :: CoreRule -> [CoreExpr]
ru_args = [CoreExpr]
args}) = [CoreExpr] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [CoreExpr]
args
ruleName :: CoreRule -> RuleName
ruleName :: CoreRule -> RuleName
ruleName = CoreRule -> RuleName
ru_name
ruleModule :: CoreRule -> Maybe Module
ruleModule :: CoreRule -> Maybe Module
ruleModule Rule { Module
ru_origin :: Module
ru_origin :: CoreRule -> Module
ru_origin } = Module -> Maybe Module
forall a. a -> Maybe a
Just Module
ru_origin
ruleModule BuiltinRule {} = Maybe Module
forall a. Maybe a
Nothing
ruleActivation :: CoreRule -> Activation
ruleActivation :: CoreRule -> Activation
ruleActivation (BuiltinRule { }) = Activation
AlwaysActive
ruleActivation (Rule { ru_act :: CoreRule -> Activation
ru_act = Activation
act }) = Activation
act
ruleIdName :: CoreRule -> Name
ruleIdName :: CoreRule -> Name
ruleIdName = CoreRule -> Name
ru_fn
isLocalRule :: CoreRule -> Bool
isLocalRule :: CoreRule -> Bool
isLocalRule = CoreRule -> Bool
ru_local
setRuleIdName :: Name -> CoreRule -> CoreRule
setRuleIdName :: Name -> CoreRule -> CoreRule
setRuleIdName Name
nm CoreRule
ru = CoreRule
ru { ru_fn :: Name
ru_fn = Name
nm }
data Unfolding
= NoUnfolding
| BootUnfolding
| OtherCon [AltCon]
| DFunUnfolding {
Unfolding -> [CoreBndr]
df_bndrs :: [Var],
Unfolding -> DataCon
df_con :: DataCon,
Unfolding -> [CoreExpr]
df_args :: [CoreExpr]
}
| CoreUnfolding {
Unfolding -> CoreExpr
uf_tmpl :: CoreExpr,
Unfolding -> UnfoldingSource
uf_src :: UnfoldingSource,
Unfolding -> Bool
uf_is_top :: Bool,
Unfolding -> Bool
uf_is_value :: Bool,
Unfolding -> Bool
uf_is_conlike :: Bool,
Unfolding -> Bool
uf_is_work_free :: Bool,
Unfolding -> Bool
uf_expandable :: Bool,
Unfolding -> UnfoldingGuidance
uf_guidance :: UnfoldingGuidance
}
data UnfoldingSource
=
InlineRhs
| InlineStable
| InlineCompulsory
data UnfoldingGuidance
= UnfWhen {
UnfoldingGuidance -> Int
ug_arity :: Arity,
UnfoldingGuidance -> Bool
ug_unsat_ok :: Bool,
UnfoldingGuidance -> Bool
ug_boring_ok :: Bool
}
| UnfIfGoodArgs {
UnfoldingGuidance -> [Int]
ug_args :: [Int],
UnfoldingGuidance -> Int
ug_size :: Int,
UnfoldingGuidance -> Int
ug_res :: Int
}
| UnfNever
deriving (UnfoldingGuidance -> UnfoldingGuidance -> Bool
(UnfoldingGuidance -> UnfoldingGuidance -> Bool)
-> (UnfoldingGuidance -> UnfoldingGuidance -> Bool)
-> Eq UnfoldingGuidance
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UnfoldingGuidance -> UnfoldingGuidance -> Bool
$c/= :: UnfoldingGuidance -> UnfoldingGuidance -> Bool
== :: UnfoldingGuidance -> UnfoldingGuidance -> Bool
$c== :: UnfoldingGuidance -> UnfoldingGuidance -> Bool
Eq)
needSaturated, unSaturatedOk :: Bool
needSaturated :: Bool
needSaturated = Bool
False
unSaturatedOk :: Bool
unSaturatedOk = Bool
True
boringCxtNotOk, boringCxtOk :: Bool
boringCxtOk :: Bool
boringCxtOk = Bool
True
boringCxtNotOk :: Bool
boringCxtNotOk = Bool
False
noUnfolding :: Unfolding
evaldUnfolding :: Unfolding
noUnfolding :: Unfolding
noUnfolding = Unfolding
NoUnfolding
evaldUnfolding :: Unfolding
evaldUnfolding = [AltCon] -> Unfolding
OtherCon []
bootUnfolding :: Unfolding
bootUnfolding :: Unfolding
bootUnfolding = Unfolding
BootUnfolding
mkOtherCon :: [AltCon] -> Unfolding
mkOtherCon :: [AltCon] -> Unfolding
mkOtherCon = [AltCon] -> Unfolding
OtherCon
isStableSource :: UnfoldingSource -> Bool
isStableSource :: UnfoldingSource -> Bool
isStableSource UnfoldingSource
InlineCompulsory = Bool
True
isStableSource UnfoldingSource
InlineStable = Bool
True
isStableSource UnfoldingSource
InlineRhs = Bool
False
unfoldingTemplate :: Unfolding -> CoreExpr
unfoldingTemplate :: Unfolding -> CoreExpr
unfoldingTemplate = Unfolding -> CoreExpr
uf_tmpl
maybeUnfoldingTemplate :: Unfolding -> Maybe CoreExpr
maybeUnfoldingTemplate :: Unfolding -> Maybe CoreExpr
maybeUnfoldingTemplate (CoreUnfolding { uf_tmpl :: Unfolding -> CoreExpr
uf_tmpl = CoreExpr
expr })
= CoreExpr -> Maybe CoreExpr
forall a. a -> Maybe a
Just CoreExpr
expr
maybeUnfoldingTemplate (DFunUnfolding { df_bndrs :: Unfolding -> [CoreBndr]
df_bndrs = [CoreBndr]
bndrs, df_con :: Unfolding -> DataCon
df_con = DataCon
con, df_args :: Unfolding -> [CoreExpr]
df_args = [CoreExpr]
args })
= CoreExpr -> Maybe CoreExpr
forall a. a -> Maybe a
Just ([CoreBndr] -> CoreExpr -> CoreExpr
forall b. [b] -> Expr b -> Expr b
mkLams [CoreBndr]
bndrs (CoreExpr -> [CoreExpr] -> CoreExpr
forall b. Expr b -> [Expr b] -> Expr b
mkApps (CoreBndr -> CoreExpr
forall b. CoreBndr -> Expr b
Var (DataCon -> CoreBndr
dataConWorkId DataCon
con)) [CoreExpr]
args))
maybeUnfoldingTemplate Unfolding
_
= Maybe CoreExpr
forall a. Maybe a
Nothing
otherCons :: Unfolding -> [AltCon]
otherCons :: Unfolding -> [AltCon]
otherCons (OtherCon [AltCon]
cons) = [AltCon]
cons
otherCons Unfolding
_ = []
isValueUnfolding :: Unfolding -> Bool
isValueUnfolding :: Unfolding -> Bool
isValueUnfolding (CoreUnfolding { uf_is_value :: Unfolding -> Bool
uf_is_value = Bool
is_evald }) = Bool
is_evald
isValueUnfolding Unfolding
_ = Bool
False
isEvaldUnfolding :: Unfolding -> Bool
isEvaldUnfolding :: Unfolding -> Bool
isEvaldUnfolding (OtherCon [AltCon]
_) = Bool
True
isEvaldUnfolding (CoreUnfolding { uf_is_value :: Unfolding -> Bool
uf_is_value = Bool
is_evald }) = Bool
is_evald
isEvaldUnfolding Unfolding
_ = Bool
False
isConLikeUnfolding :: Unfolding -> Bool
isConLikeUnfolding :: Unfolding -> Bool
isConLikeUnfolding (OtherCon [AltCon]
_) = Bool
True
isConLikeUnfolding (CoreUnfolding { uf_is_conlike :: Unfolding -> Bool
uf_is_conlike = Bool
con }) = Bool
con
isConLikeUnfolding Unfolding
_ = Bool
False
isCheapUnfolding :: Unfolding -> Bool
isCheapUnfolding :: Unfolding -> Bool
isCheapUnfolding (CoreUnfolding { uf_is_work_free :: Unfolding -> Bool
uf_is_work_free = Bool
is_wf }) = Bool
is_wf
isCheapUnfolding Unfolding
_ = Bool
False
isExpandableUnfolding :: Unfolding -> Bool
isExpandableUnfolding :: Unfolding -> Bool
isExpandableUnfolding (CoreUnfolding { uf_expandable :: Unfolding -> Bool
uf_expandable = Bool
is_expable }) = Bool
is_expable
isExpandableUnfolding Unfolding
_ = Bool
False
expandUnfolding_maybe :: Unfolding -> Maybe CoreExpr
expandUnfolding_maybe :: Unfolding -> Maybe CoreExpr
expandUnfolding_maybe (CoreUnfolding { uf_expandable :: Unfolding -> Bool
uf_expandable = Bool
True, uf_tmpl :: Unfolding -> CoreExpr
uf_tmpl = CoreExpr
rhs }) = CoreExpr -> Maybe CoreExpr
forall a. a -> Maybe a
Just CoreExpr
rhs
expandUnfolding_maybe Unfolding
_ = Maybe CoreExpr
forall a. Maybe a
Nothing
isCompulsoryUnfolding :: Unfolding -> Bool
isCompulsoryUnfolding :: Unfolding -> Bool
isCompulsoryUnfolding (CoreUnfolding { uf_src :: Unfolding -> UnfoldingSource
uf_src = UnfoldingSource
InlineCompulsory }) = Bool
True
isCompulsoryUnfolding Unfolding
_ = Bool
False
isStableUnfolding :: Unfolding -> Bool
isStableUnfolding :: Unfolding -> Bool
isStableUnfolding (CoreUnfolding { uf_src :: Unfolding -> UnfoldingSource
uf_src = UnfoldingSource
src }) = UnfoldingSource -> Bool
isStableSource UnfoldingSource
src
isStableUnfolding (DFunUnfolding {}) = Bool
True
isStableUnfolding Unfolding
_ = Bool
False
hasSomeUnfolding :: Unfolding -> Bool
hasSomeUnfolding :: Unfolding -> Bool
hasSomeUnfolding Unfolding
NoUnfolding = Bool
False
hasSomeUnfolding Unfolding
BootUnfolding = Bool
False
hasSomeUnfolding Unfolding
_ = Bool
True
isBootUnfolding :: Unfolding -> Bool
isBootUnfolding :: Unfolding -> Bool
isBootUnfolding Unfolding
BootUnfolding = Bool
True
isBootUnfolding Unfolding
_ = Bool
False
neverUnfoldGuidance :: UnfoldingGuidance -> Bool
neverUnfoldGuidance :: UnfoldingGuidance -> Bool
neverUnfoldGuidance UnfoldingGuidance
UnfNever = Bool
True
neverUnfoldGuidance UnfoldingGuidance
_ = Bool
False
isFragileUnfolding :: Unfolding -> Bool
isFragileUnfolding :: Unfolding -> Bool
isFragileUnfolding (CoreUnfolding {}) = Bool
True
isFragileUnfolding (DFunUnfolding {}) = Bool
True
isFragileUnfolding Unfolding
_ = Bool
False
canUnfold :: Unfolding -> Bool
canUnfold :: Unfolding -> Bool
canUnfold (CoreUnfolding { uf_guidance :: Unfolding -> UnfoldingGuidance
uf_guidance = UnfoldingGuidance
g }) = Bool -> Bool
not (UnfoldingGuidance -> Bool
neverUnfoldGuidance UnfoldingGuidance
g)
canUnfold Unfolding
_ = Bool
False
instance Outputable AltCon where
ppr :: AltCon -> SDoc
ppr (DataAlt DataCon
dc) = DataCon -> SDoc
forall a. Outputable a => a -> SDoc
ppr DataCon
dc
ppr (LitAlt Literal
lit) = Literal -> SDoc
forall a. Outputable a => a -> SDoc
ppr Literal
lit
ppr AltCon
DEFAULT = String -> SDoc
text String
"__DEFAULT"
cmpAlt :: (AltCon, a, b) -> (AltCon, a, b) -> Ordering
cmpAlt :: (AltCon, a, b) -> (AltCon, a, b) -> Ordering
cmpAlt (AltCon
con1, a
_, b
_) (AltCon
con2, a
_, b
_) = AltCon
con1 AltCon -> AltCon -> Ordering
`cmpAltCon` AltCon
con2
ltAlt :: (AltCon, a, b) -> (AltCon, a, b) -> Bool
ltAlt :: (AltCon, a, b) -> (AltCon, a, b) -> Bool
ltAlt (AltCon, a, b)
a1 (AltCon, a, b)
a2 = ((AltCon, a, b)
a1 (AltCon, a, b) -> (AltCon, a, b) -> Ordering
forall a b. (AltCon, a, b) -> (AltCon, a, b) -> Ordering
`cmpAlt` (AltCon, a, b)
a2) Ordering -> Ordering -> Bool
forall a. Eq a => a -> a -> Bool
== Ordering
LT
cmpAltCon :: AltCon -> AltCon -> Ordering
cmpAltCon :: AltCon -> AltCon -> Ordering
cmpAltCon AltCon
DEFAULT AltCon
DEFAULT = Ordering
EQ
cmpAltCon AltCon
DEFAULT AltCon
_ = Ordering
LT
cmpAltCon (DataAlt DataCon
d1) (DataAlt DataCon
d2) = DataCon -> Int
dataConTag DataCon
d1 Int -> Int -> Ordering
forall a. Ord a => a -> a -> Ordering
`compare` DataCon -> Int
dataConTag DataCon
d2
cmpAltCon (DataAlt DataCon
_) AltCon
DEFAULT = Ordering
GT
cmpAltCon (LitAlt Literal
l1) (LitAlt Literal
l2) = Literal
l1 Literal -> Literal -> Ordering
forall a. Ord a => a -> a -> Ordering
`compare` Literal
l2
cmpAltCon (LitAlt Literal
_) AltCon
DEFAULT = Ordering
GT
cmpAltCon AltCon
con1 AltCon
con2 = WARN( True, text "Comparing incomparable AltCons" <+>
ppr con1 <+> ppr con2 )
Ordering
LT
type CoreProgram = [CoreBind]
type CoreBndr = Var
type CoreExpr = Expr CoreBndr
type CoreArg = Arg CoreBndr
type CoreBind = Bind CoreBndr
type CoreAlt = Alt CoreBndr
data TaggedBndr t = TB CoreBndr t
type TaggedBind t = Bind (TaggedBndr t)
type TaggedExpr t = Expr (TaggedBndr t)
type TaggedArg t = Arg (TaggedBndr t)
type TaggedAlt t = Alt (TaggedBndr t)
instance Outputable b => Outputable (TaggedBndr b) where
ppr :: TaggedBndr b -> SDoc
ppr (TB CoreBndr
b b
l) = Char -> SDoc
char Char
'<' SDoc -> SDoc -> SDoc
<> CoreBndr -> SDoc
forall a. Outputable a => a -> SDoc
ppr CoreBndr
b SDoc -> SDoc -> SDoc
<> SDoc
comma SDoc -> SDoc -> SDoc
<> b -> SDoc
forall a. Outputable a => a -> SDoc
ppr b
l SDoc -> SDoc -> SDoc
<> Char -> SDoc
char Char
'>'
deTagExpr :: TaggedExpr t -> CoreExpr
deTagExpr :: TaggedExpr t -> CoreExpr
deTagExpr (Var CoreBndr
v) = CoreBndr -> CoreExpr
forall b. CoreBndr -> Expr b
Var CoreBndr
v
deTagExpr (Lit Literal
l) = Literal -> CoreExpr
forall b. Literal -> Expr b
Lit Literal
l
deTagExpr (Type Type
ty) = Type -> CoreExpr
forall b. Type -> Expr b
Type Type
ty
deTagExpr (Coercion Coercion
co) = Coercion -> CoreExpr
forall b. Coercion -> Expr b
Coercion Coercion
co
deTagExpr (App TaggedExpr t
e1 TaggedExpr t
e2) = CoreExpr -> CoreExpr -> CoreExpr
forall b. Expr b -> Expr b -> Expr b
App (TaggedExpr t -> CoreExpr
forall t. TaggedExpr t -> CoreExpr
deTagExpr TaggedExpr t
e1) (TaggedExpr t -> CoreExpr
forall t. TaggedExpr t -> CoreExpr
deTagExpr TaggedExpr t
e2)
deTagExpr (Lam (TB CoreBndr
b t
_) TaggedExpr t
e) = CoreBndr -> CoreExpr -> CoreExpr
forall b. b -> Expr b -> Expr b
Lam CoreBndr
b (TaggedExpr t -> CoreExpr
forall t. TaggedExpr t -> CoreExpr
deTagExpr TaggedExpr t
e)
deTagExpr (Let Bind (TaggedBndr t)
bind TaggedExpr t
body) = Bind CoreBndr -> CoreExpr -> CoreExpr
forall b. Bind b -> Expr b -> Expr b
Let (Bind (TaggedBndr t) -> Bind CoreBndr
forall t. TaggedBind t -> Bind CoreBndr
deTagBind Bind (TaggedBndr t)
bind) (TaggedExpr t -> CoreExpr
forall t. TaggedExpr t -> CoreExpr
deTagExpr TaggedExpr t
body)
deTagExpr (Case TaggedExpr t
e (TB CoreBndr
b t
_) Type
ty [Alt (TaggedBndr t)]
alts) = CoreExpr -> CoreBndr -> Type -> [Alt CoreBndr] -> CoreExpr
forall b. Expr b -> b -> Type -> [Alt b] -> Expr b
Case (TaggedExpr t -> CoreExpr
forall t. TaggedExpr t -> CoreExpr
deTagExpr TaggedExpr t
e) CoreBndr
b Type
ty ((Alt (TaggedBndr t) -> Alt CoreBndr)
-> [Alt (TaggedBndr t)] -> [Alt CoreBndr]
forall a b. (a -> b) -> [a] -> [b]
map Alt (TaggedBndr t) -> Alt CoreBndr
forall t. TaggedAlt t -> Alt CoreBndr
deTagAlt [Alt (TaggedBndr t)]
alts)
deTagExpr (Tick Tickish CoreBndr
t TaggedExpr t
e) = Tickish CoreBndr -> CoreExpr -> CoreExpr
forall b. Tickish CoreBndr -> Expr b -> Expr b
Tick Tickish CoreBndr
t (TaggedExpr t -> CoreExpr
forall t. TaggedExpr t -> CoreExpr
deTagExpr TaggedExpr t
e)
deTagExpr (Cast TaggedExpr t
e Coercion
co) = CoreExpr -> Coercion -> CoreExpr
forall b. Expr b -> Coercion -> Expr b
Cast (TaggedExpr t -> CoreExpr
forall t. TaggedExpr t -> CoreExpr
deTagExpr TaggedExpr t
e) Coercion
co
deTagBind :: TaggedBind t -> CoreBind
deTagBind :: TaggedBind t -> Bind CoreBndr
deTagBind (NonRec (TB CoreBndr
b t
_) Expr (TaggedBndr t)
rhs) = CoreBndr -> CoreExpr -> Bind CoreBndr
forall b. b -> Expr b -> Bind b
NonRec CoreBndr
b (Expr (TaggedBndr t) -> CoreExpr
forall t. TaggedExpr t -> CoreExpr
deTagExpr Expr (TaggedBndr t)
rhs)
deTagBind (Rec [(TaggedBndr t, Expr (TaggedBndr t))]
prs) = [(CoreBndr, CoreExpr)] -> Bind CoreBndr
forall b. [(b, Expr b)] -> Bind b
Rec [(CoreBndr
b, Expr (TaggedBndr t) -> CoreExpr
forall t. TaggedExpr t -> CoreExpr
deTagExpr Expr (TaggedBndr t)
rhs) | (TB CoreBndr
b t
_, Expr (TaggedBndr t)
rhs) <- [(TaggedBndr t, Expr (TaggedBndr t))]
prs]
deTagAlt :: TaggedAlt t -> CoreAlt
deTagAlt :: TaggedAlt t -> Alt CoreBndr
deTagAlt (AltCon
con, [TaggedBndr t]
bndrs, Expr (TaggedBndr t)
rhs) = (AltCon
con, [CoreBndr
b | TB CoreBndr
b t
_ <- [TaggedBndr t]
bndrs], Expr (TaggedBndr t) -> CoreExpr
forall t. TaggedExpr t -> CoreExpr
deTagExpr Expr (TaggedBndr t)
rhs)
mkApps :: Expr b -> [Arg b] -> Expr b
mkTyApps :: Expr b -> [Type] -> Expr b
mkCoApps :: Expr b -> [Coercion] -> Expr b
mkVarApps :: Expr b -> [Var] -> Expr b
mkConApp :: DataCon -> [Arg b] -> Expr b
mkApps :: Expr b -> [Expr b] -> Expr b
mkApps Expr b
f [Expr b]
args = (Expr b -> Expr b -> Expr b) -> Expr b -> [Expr b] -> Expr b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' Expr b -> Expr b -> Expr b
forall b. Expr b -> Expr b -> Expr b
App Expr b
f [Expr b]
args
mkCoApps :: Expr b -> [Coercion] -> Expr b
mkCoApps Expr b
f [Coercion]
args = (Expr b -> Coercion -> Expr b) -> Expr b -> [Coercion] -> Expr b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' (\ Expr b
e Coercion
a -> Expr b -> Expr b -> Expr b
forall b. Expr b -> Expr b -> Expr b
App Expr b
e (Coercion -> Expr b
forall b. Coercion -> Expr b
Coercion Coercion
a)) Expr b
f [Coercion]
args
mkVarApps :: Expr b -> [CoreBndr] -> Expr b
mkVarApps Expr b
f [CoreBndr]
vars = (Expr b -> CoreBndr -> Expr b) -> Expr b -> [CoreBndr] -> Expr b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' (\ Expr b
e CoreBndr
a -> Expr b -> Expr b -> Expr b
forall b. Expr b -> Expr b -> Expr b
App Expr b
e (CoreBndr -> Expr b
forall b. CoreBndr -> Expr b
varToCoreExpr CoreBndr
a)) Expr b
f [CoreBndr]
vars
mkConApp :: DataCon -> [Arg b] -> Arg b
mkConApp DataCon
con [Arg b]
args = Arg b -> [Arg b] -> Arg b
forall b. Expr b -> [Expr b] -> Expr b
mkApps (CoreBndr -> Arg b
forall b. CoreBndr -> Expr b
Var (DataCon -> CoreBndr
dataConWorkId DataCon
con)) [Arg b]
args
mkTyApps :: Expr b -> [Type] -> Expr b
mkTyApps Expr b
f [Type]
args = (Expr b -> Type -> Expr b) -> Expr b -> [Type] -> Expr b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' (\ Expr b
e Type
a -> Expr b -> Expr b -> Expr b
forall b. Expr b -> Expr b -> Expr b
App Expr b
e (Type -> Expr b
forall b. Type -> Expr b
mkTyArg Type
a)) Expr b
f [Type]
args
mkConApp2 :: DataCon -> [Type] -> [Var] -> Expr b
mkConApp2 :: DataCon -> [Type] -> [CoreBndr] -> Expr b
mkConApp2 DataCon
con [Type]
tys [CoreBndr]
arg_ids = CoreBndr -> Expr b
forall b. CoreBndr -> Expr b
Var (DataCon -> CoreBndr
dataConWorkId DataCon
con)
Expr b -> [Expr b] -> Expr b
forall b. Expr b -> [Expr b] -> Expr b
`mkApps` (Type -> Expr b) -> [Type] -> [Expr b]
forall a b. (a -> b) -> [a] -> [b]
map Type -> Expr b
forall b. Type -> Expr b
Type [Type]
tys
Expr b -> [Expr b] -> Expr b
forall b. Expr b -> [Expr b] -> Expr b
`mkApps` (CoreBndr -> Expr b) -> [CoreBndr] -> [Expr b]
forall a b. (a -> b) -> [a] -> [b]
map CoreBndr -> Expr b
forall b. CoreBndr -> Expr b
varToCoreExpr [CoreBndr]
arg_ids
mkTyArg :: Type -> Expr b
mkTyArg :: Type -> Expr b
mkTyArg Type
ty
| Just Coercion
co <- Type -> Maybe Coercion
isCoercionTy_maybe Type
ty = Coercion -> Expr b
forall b. Coercion -> Expr b
Coercion Coercion
co
| Bool
otherwise = Type -> Expr b
forall b. Type -> Expr b
Type Type
ty
mkIntLit :: DynFlags -> Integer -> Expr b
mkIntLitInt :: DynFlags -> Int -> Expr b
mkIntLit :: DynFlags -> Integer -> Expr b
mkIntLit DynFlags
dflags Integer
n = Literal -> Expr b
forall b. Literal -> Expr b
Lit (DynFlags -> Integer -> Literal
mkLitInt DynFlags
dflags Integer
n)
mkIntLitInt :: DynFlags -> Int -> Expr b
mkIntLitInt DynFlags
dflags Int
n = Literal -> Expr b
forall b. Literal -> Expr b
Lit (DynFlags -> Integer -> Literal
mkLitInt DynFlags
dflags (Int -> Integer
forall a. Integral a => a -> Integer
toInteger Int
n))
mkWordLit :: DynFlags -> Integer -> Expr b
mkWordLitWord :: DynFlags -> Word -> Expr b
mkWordLit :: DynFlags -> Integer -> Expr b
mkWordLit DynFlags
dflags Integer
w = Literal -> Expr b
forall b. Literal -> Expr b
Lit (DynFlags -> Integer -> Literal
mkLitWord DynFlags
dflags Integer
w)
mkWordLitWord :: DynFlags -> Word -> Expr b
mkWordLitWord DynFlags
dflags Word
w = Literal -> Expr b
forall b. Literal -> Expr b
Lit (DynFlags -> Integer -> Literal
mkLitWord DynFlags
dflags (Word -> Integer
forall a. Integral a => a -> Integer
toInteger Word
w))
mkWord64LitWord64 :: Word64 -> Expr b
mkWord64LitWord64 :: Word64 -> Expr b
mkWord64LitWord64 Word64
w = Literal -> Expr b
forall b. Literal -> Expr b
Lit (Integer -> Literal
mkLitWord64 (Word64 -> Integer
forall a. Integral a => a -> Integer
toInteger Word64
w))
mkInt64LitInt64 :: Int64 -> Expr b
mkInt64LitInt64 :: Int64 -> Expr b
mkInt64LitInt64 Int64
w = Literal -> Expr b
forall b. Literal -> Expr b
Lit (Integer -> Literal
mkLitInt64 (Int64 -> Integer
forall a. Integral a => a -> Integer
toInteger Int64
w))
mkCharLit :: Char -> Expr b
mkStringLit :: String -> Expr b
mkCharLit :: Char -> Expr b
mkCharLit Char
c = Literal -> Expr b
forall b. Literal -> Expr b
Lit (Char -> Literal
mkLitChar Char
c)
mkStringLit :: String -> Expr b
mkStringLit String
s = Literal -> Expr b
forall b. Literal -> Expr b
Lit (String -> Literal
mkLitString String
s)
mkFloatLit :: Rational -> Expr b
mkFloatLitFloat :: Float -> Expr b
mkFloatLit :: Rational -> Expr b
mkFloatLit Rational
f = Literal -> Expr b
forall b. Literal -> Expr b
Lit (Rational -> Literal
mkLitFloat Rational
f)
mkFloatLitFloat :: Float -> Expr b
mkFloatLitFloat Float
f = Literal -> Expr b
forall b. Literal -> Expr b
Lit (Rational -> Literal
mkLitFloat (Float -> Rational
forall a. Real a => a -> Rational
toRational Float
f))
mkDoubleLit :: Rational -> Expr b
mkDoubleLitDouble :: Double -> Expr b
mkDoubleLit :: Rational -> Expr b
mkDoubleLit Rational
d = Literal -> Expr b
forall b. Literal -> Expr b
Lit (Rational -> Literal
mkLitDouble Rational
d)
mkDoubleLitDouble :: Double -> Expr b
mkDoubleLitDouble Double
d = Literal -> Expr b
forall b. Literal -> Expr b
Lit (Rational -> Literal
mkLitDouble (Double -> Rational
forall a. Real a => a -> Rational
toRational Double
d))
mkLets :: [Bind b] -> Expr b -> Expr b
mkLams :: [b] -> Expr b -> Expr b
mkLams :: [b] -> Expr b -> Expr b
mkLams [b]
binders Expr b
body = (b -> Expr b -> Expr b) -> Expr b -> [b] -> Expr b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr b -> Expr b -> Expr b
forall b. b -> Expr b -> Expr b
Lam Expr b
body [b]
binders
mkLets :: [Bind b] -> Expr b -> Expr b
mkLets [Bind b]
binds Expr b
body = (Bind b -> Expr b -> Expr b) -> Expr b -> [Bind b] -> Expr b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr Bind b -> Expr b -> Expr b
forall b. Bind b -> Expr b -> Expr b
mkLet Expr b
body [Bind b]
binds
mkLet :: Bind b -> Expr b -> Expr b
mkLet :: Bind b -> Expr b -> Expr b
mkLet (Rec []) Expr b
body = Expr b
body
mkLet Bind b
bind Expr b
body = Bind b -> Expr b -> Expr b
forall b. Bind b -> Expr b -> Expr b
Let Bind b
bind Expr b
body
mkLetNonRec :: b -> Expr b -> Expr b -> Expr b
mkLetNonRec :: b -> Expr b -> Expr b -> Expr b
mkLetNonRec b
b Expr b
rhs Expr b
body = Bind b -> Expr b -> Expr b
forall b. Bind b -> Expr b -> Expr b
Let (b -> Expr b -> Bind b
forall b. b -> Expr b -> Bind b
NonRec b
b Expr b
rhs) Expr b
body
mkLetRec :: [(b, Expr b)] -> Expr b -> Expr b
mkLetRec :: [(b, Expr b)] -> Expr b -> Expr b
mkLetRec [] Expr b
body = Expr b
body
mkLetRec [(b, Expr b)]
bs Expr b
body = Bind b -> Expr b -> Expr b
forall b. Bind b -> Expr b -> Expr b
Let ([(b, Expr b)] -> Bind b
forall b. [(b, Expr b)] -> Bind b
Rec [(b, Expr b)]
bs) Expr b
body
mkTyBind :: TyVar -> Type -> CoreBind
mkTyBind :: CoreBndr -> Type -> Bind CoreBndr
mkTyBind CoreBndr
tv Type
ty = CoreBndr -> CoreExpr -> Bind CoreBndr
forall b. b -> Expr b -> Bind b
NonRec CoreBndr
tv (Type -> CoreExpr
forall b. Type -> Expr b
Type Type
ty)
mkCoBind :: CoVar -> Coercion -> CoreBind
mkCoBind :: CoreBndr -> Coercion -> Bind CoreBndr
mkCoBind CoreBndr
cv Coercion
co = CoreBndr -> CoreExpr -> Bind CoreBndr
forall b. b -> Expr b -> Bind b
NonRec CoreBndr
cv (Coercion -> CoreExpr
forall b. Coercion -> Expr b
Coercion Coercion
co)
varToCoreExpr :: CoreBndr -> Expr b
varToCoreExpr :: CoreBndr -> Expr b
varToCoreExpr CoreBndr
v | CoreBndr -> Bool
isTyVar CoreBndr
v = Type -> Expr b
forall b. Type -> Expr b
Type (CoreBndr -> Type
mkTyVarTy CoreBndr
v)
| CoreBndr -> Bool
isCoVar CoreBndr
v = Coercion -> Expr b
forall b. Coercion -> Expr b
Coercion (CoreBndr -> Coercion
mkCoVarCo CoreBndr
v)
| Bool
otherwise = ASSERT( isId v ) Var v
varsToCoreExprs :: [CoreBndr] -> [Expr b]
varsToCoreExprs :: [CoreBndr] -> [Expr b]
varsToCoreExprs [CoreBndr]
vs = (CoreBndr -> Expr b) -> [CoreBndr] -> [Expr b]
forall a b. (a -> b) -> [a] -> [b]
map CoreBndr -> Expr b
forall b. CoreBndr -> Expr b
varToCoreExpr [CoreBndr]
vs
applyTypeToArg :: Type -> CoreExpr -> Type
applyTypeToArg :: Type -> CoreExpr -> Type
applyTypeToArg Type
fun_ty CoreExpr
arg = HasDebugCallStack => Type -> Type -> Type
Type -> Type -> Type
piResultTy Type
fun_ty (CoreExpr -> Type
exprToType CoreExpr
arg)
exprToType :: CoreExpr -> Type
exprToType :: CoreExpr -> Type
exprToType (Type Type
ty) = Type
ty
exprToType CoreExpr
_bad = String -> SDoc -> Type
forall a. HasCallStack => String -> SDoc -> a
pprPanic String
"exprToType" SDoc
empty
exprToCoercion_maybe :: CoreExpr -> Maybe Coercion
exprToCoercion_maybe :: CoreExpr -> Maybe Coercion
exprToCoercion_maybe (Coercion Coercion
co) = Coercion -> Maybe Coercion
forall a. a -> Maybe a
Just Coercion
co
exprToCoercion_maybe CoreExpr
_ = Maybe Coercion
forall a. Maybe a
Nothing
bindersOf :: Bind b -> [b]
bindersOf :: Bind b -> [b]
bindersOf (NonRec b
binder Expr b
_) = [b
binder]
bindersOf (Rec [(b, Expr b)]
pairs) = [b
binder | (b
binder, Expr b
_) <- [(b, Expr b)]
pairs]
bindersOfBinds :: [Bind b] -> [b]
bindersOfBinds :: [Bind b] -> [b]
bindersOfBinds [Bind b]
binds = (Bind b -> [b] -> [b]) -> [b] -> [Bind b] -> [b]
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr ([b] -> [b] -> [b]
forall a. [a] -> [a] -> [a]
(++) ([b] -> [b] -> [b]) -> (Bind b -> [b]) -> Bind b -> [b] -> [b]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bind b -> [b]
forall b. Bind b -> [b]
bindersOf) [] [Bind b]
binds
rhssOfBind :: Bind b -> [Expr b]
rhssOfBind :: Bind b -> [Expr b]
rhssOfBind (NonRec b
_ Expr b
rhs) = [Expr b
rhs]
rhssOfBind (Rec [(b, Expr b)]
pairs) = [Expr b
rhs | (b
_,Expr b
rhs) <- [(b, Expr b)]
pairs]
rhssOfAlts :: [Alt b] -> [Expr b]
rhssOfAlts :: [Alt b] -> [Expr b]
rhssOfAlts [Alt b]
alts = [Expr b
e | (AltCon
_,[b]
_,Expr b
e) <- [Alt b]
alts]
flattenBinds :: [Bind b] -> [(b, Expr b)]
flattenBinds :: [Bind b] -> [(b, Expr b)]
flattenBinds (NonRec b
b Expr b
r : [Bind b]
binds) = (b
b,Expr b
r) (b, Expr b) -> [(b, Expr b)] -> [(b, Expr b)]
forall a. a -> [a] -> [a]
: [Bind b] -> [(b, Expr b)]
forall b. [Bind b] -> [(b, Expr b)]
flattenBinds [Bind b]
binds
flattenBinds (Rec [(b, Expr b)]
prs1 : [Bind b]
binds) = [(b, Expr b)]
prs1 [(b, Expr b)] -> [(b, Expr b)] -> [(b, Expr b)]
forall a. [a] -> [a] -> [a]
++ [Bind b] -> [(b, Expr b)]
forall b. [Bind b] -> [(b, Expr b)]
flattenBinds [Bind b]
binds
flattenBinds [] = []
collectBinders :: Expr b -> ([b], Expr b)
collectTyBinders :: CoreExpr -> ([TyVar], CoreExpr)
collectValBinders :: CoreExpr -> ([Id], CoreExpr)
collectTyAndValBinders :: CoreExpr -> ([TyVar], [Id], CoreExpr)
collectNBinders :: Int -> Expr b -> ([b], Expr b)
collectBinders :: Expr b -> ([b], Expr b)
collectBinders Expr b
expr
= [b] -> Expr b -> ([b], Expr b)
forall a. [a] -> Expr a -> ([a], Expr a)
go [] Expr b
expr
where
go :: [a] -> Expr a -> ([a], Expr a)
go [a]
bs (Lam a
b Expr a
e) = [a] -> Expr a -> ([a], Expr a)
go (a
ba -> [a] -> [a]
forall a. a -> [a] -> [a]
:[a]
bs) Expr a
e
go [a]
bs Expr a
e = ([a] -> [a]
forall a. [a] -> [a]
reverse [a]
bs, Expr a
e)
collectTyBinders :: CoreExpr -> ([CoreBndr], CoreExpr)
collectTyBinders CoreExpr
expr
= [CoreBndr] -> CoreExpr -> ([CoreBndr], CoreExpr)
go [] CoreExpr
expr
where
go :: [CoreBndr] -> CoreExpr -> ([CoreBndr], CoreExpr)
go [CoreBndr]
tvs (Lam CoreBndr
b CoreExpr
e) | CoreBndr -> Bool
isTyVar CoreBndr
b = [CoreBndr] -> CoreExpr -> ([CoreBndr], CoreExpr)
go (CoreBndr
bCoreBndr -> [CoreBndr] -> [CoreBndr]
forall a. a -> [a] -> [a]
:[CoreBndr]
tvs) CoreExpr
e
go [CoreBndr]
tvs CoreExpr
e = ([CoreBndr] -> [CoreBndr]
forall a. [a] -> [a]
reverse [CoreBndr]
tvs, CoreExpr
e)
collectValBinders :: CoreExpr -> ([CoreBndr], CoreExpr)
collectValBinders CoreExpr
expr
= [CoreBndr] -> CoreExpr -> ([CoreBndr], CoreExpr)
go [] CoreExpr
expr
where
go :: [CoreBndr] -> CoreExpr -> ([CoreBndr], CoreExpr)
go [CoreBndr]
ids (Lam CoreBndr
b CoreExpr
e) | CoreBndr -> Bool
isId CoreBndr
b = [CoreBndr] -> CoreExpr -> ([CoreBndr], CoreExpr)
go (CoreBndr
bCoreBndr -> [CoreBndr] -> [CoreBndr]
forall a. a -> [a] -> [a]
:[CoreBndr]
ids) CoreExpr
e
go [CoreBndr]
ids CoreExpr
body = ([CoreBndr] -> [CoreBndr]
forall a. [a] -> [a]
reverse [CoreBndr]
ids, CoreExpr
body)
collectTyAndValBinders :: CoreExpr -> ([CoreBndr], [CoreBndr], CoreExpr)
collectTyAndValBinders CoreExpr
expr
= ([CoreBndr]
tvs, [CoreBndr]
ids, CoreExpr
body)
where
([CoreBndr]
tvs, CoreExpr
body1) = CoreExpr -> ([CoreBndr], CoreExpr)
collectTyBinders CoreExpr
expr
([CoreBndr]
ids, CoreExpr
body) = CoreExpr -> ([CoreBndr], CoreExpr)
collectValBinders CoreExpr
body1
collectNBinders :: Int -> Expr b -> ([b], Expr b)
collectNBinders Int
orig_n Expr b
orig_expr
= Int -> [b] -> Expr b -> ([b], Expr b)
forall t a. (Eq t, Num t) => t -> [a] -> Expr a -> ([a], Expr a)
go Int
orig_n [] Expr b
orig_expr
where
go :: t -> [a] -> Expr a -> ([a], Expr a)
go t
0 [a]
bs Expr a
expr = ([a] -> [a]
forall a. [a] -> [a]
reverse [a]
bs, Expr a
expr)
go t
n [a]
bs (Lam a
b Expr a
e) = t -> [a] -> Expr a -> ([a], Expr a)
go (t
nt -> t -> t
forall a. Num a => a -> a -> a
-t
1) (a
ba -> [a] -> [a]
forall a. a -> [a] -> [a]
:[a]
bs) Expr a
e
go t
_ [a]
_ Expr a
_ = String -> SDoc -> ([a], Expr a)
forall a. HasCallStack => String -> SDoc -> a
pprPanic String
"collectNBinders" (SDoc -> ([a], Expr a)) -> SDoc -> ([a], Expr a)
forall a b. (a -> b) -> a -> b
$ Int -> SDoc
int Int
orig_n
collectArgs :: Expr b -> (Expr b, [Arg b])
collectArgs :: Expr b -> (Expr b, [Expr b])
collectArgs Expr b
expr
= Expr b -> [Expr b] -> (Expr b, [Expr b])
forall b. Expr b -> [Expr b] -> (Expr b, [Expr b])
go Expr b
expr []
where
go :: Expr b -> [Expr b] -> (Expr b, [Expr b])
go (App Expr b
f Expr b
a) [Expr b]
as = Expr b -> [Expr b] -> (Expr b, [Expr b])
go Expr b
f (Expr b
aExpr b -> [Expr b] -> [Expr b]
forall a. a -> [a] -> [a]
:[Expr b]
as)
go Expr b
e [Expr b]
as = (Expr b
e, [Expr b]
as)
stripNArgs :: Word -> Expr a -> Maybe (Expr a)
stripNArgs :: Word -> Expr a -> Maybe (Expr a)
stripNArgs !Word
n (Tick Tickish CoreBndr
_ Expr a
e) = Word -> Expr a -> Maybe (Expr a)
forall a. Word -> Expr a -> Maybe (Expr a)
stripNArgs Word
n Expr a
e
stripNArgs Word
n (Cast Expr a
f Coercion
_) = Word -> Expr a -> Maybe (Expr a)
forall a. Word -> Expr a -> Maybe (Expr a)
stripNArgs Word
n Expr a
f
stripNArgs Word
0 Expr a
e = Expr a -> Maybe (Expr a)
forall a. a -> Maybe a
Just Expr a
e
stripNArgs Word
n (App Expr a
f Expr a
_) = Word -> Expr a -> Maybe (Expr a)
forall a. Word -> Expr a -> Maybe (Expr a)
stripNArgs (Word
n Word -> Word -> Word
forall a. Num a => a -> a -> a
- Word
1) Expr a
f
stripNArgs Word
_ Expr a
_ = Maybe (Expr a)
forall a. Maybe a
Nothing
collectArgsTicks :: (Tickish Id -> Bool) -> Expr b
-> (Expr b, [Arg b], [Tickish Id])
collectArgsTicks :: (Tickish CoreBndr -> Bool)
-> Expr b -> (Expr b, [Expr b], [Tickish CoreBndr])
collectArgsTicks Tickish CoreBndr -> Bool
skipTick Expr b
expr
= Expr b
-> [Expr b]
-> [Tickish CoreBndr]
-> (Expr b, [Expr b], [Tickish CoreBndr])
forall b.
Expr b
-> [Expr b]
-> [Tickish CoreBndr]
-> (Expr b, [Expr b], [Tickish CoreBndr])
go Expr b
expr [] []
where
go :: Expr b
-> [Expr b]
-> [Tickish CoreBndr]
-> (Expr b, [Expr b], [Tickish CoreBndr])
go (App Expr b
f Expr b
a) [Expr b]
as [Tickish CoreBndr]
ts = Expr b
-> [Expr b]
-> [Tickish CoreBndr]
-> (Expr b, [Expr b], [Tickish CoreBndr])
go Expr b
f (Expr b
aExpr b -> [Expr b] -> [Expr b]
forall a. a -> [a] -> [a]
:[Expr b]
as) [Tickish CoreBndr]
ts
go (Tick Tickish CoreBndr
t Expr b
e) [Expr b]
as [Tickish CoreBndr]
ts
| Tickish CoreBndr -> Bool
skipTick Tickish CoreBndr
t = Expr b
-> [Expr b]
-> [Tickish CoreBndr]
-> (Expr b, [Expr b], [Tickish CoreBndr])
go Expr b
e [Expr b]
as (Tickish CoreBndr
tTickish CoreBndr -> [Tickish CoreBndr] -> [Tickish CoreBndr]
forall a. a -> [a] -> [a]
:[Tickish CoreBndr]
ts)
go Expr b
e [Expr b]
as [Tickish CoreBndr]
ts = (Expr b
e, [Expr b]
as, [Tickish CoreBndr] -> [Tickish CoreBndr]
forall a. [a] -> [a]
reverse [Tickish CoreBndr]
ts)
isRuntimeVar :: Var -> Bool
isRuntimeVar :: CoreBndr -> Bool
isRuntimeVar = CoreBndr -> Bool
isId
isRuntimeArg :: CoreExpr -> Bool
isRuntimeArg :: CoreExpr -> Bool
isRuntimeArg = CoreExpr -> Bool
forall b. Expr b -> Bool
isValArg
isValArg :: Expr b -> Bool
isValArg :: Expr b -> Bool
isValArg Expr b
e = Bool -> Bool
not (Expr b -> Bool
forall b. Expr b -> Bool
isTypeArg Expr b
e)
isTyCoArg :: Expr b -> Bool
isTyCoArg :: Expr b -> Bool
isTyCoArg (Type {}) = Bool
True
isTyCoArg (Coercion {}) = Bool
True
isTyCoArg Expr b
_ = Bool
False
isCoArg :: Expr b -> Bool
isCoArg :: Expr b -> Bool
isCoArg (Coercion {}) = Bool
True
isCoArg Expr b
_ = Bool
False
isTypeArg :: Expr b -> Bool
isTypeArg :: Expr b -> Bool
isTypeArg (Type {}) = Bool
True
isTypeArg Expr b
_ = Bool
False
valBndrCount :: [CoreBndr] -> Int
valBndrCount :: [CoreBndr] -> Int
valBndrCount = (CoreBndr -> Bool) -> [CoreBndr] -> Int
forall a. (a -> Bool) -> [a] -> Int
count CoreBndr -> Bool
isId
valArgCount :: [Arg b] -> Int
valArgCount :: [Arg b] -> Int
valArgCount = (Arg b -> Bool) -> [Arg b] -> Int
forall a. (a -> Bool) -> [a] -> Int
count Arg b -> Bool
forall b. Expr b -> Bool
isValArg
type AnnExpr bndr annot = (annot, AnnExpr' bndr annot)
data AnnExpr' bndr annot
= AnnVar Id
| AnnLit Literal
| AnnLam bndr (AnnExpr bndr annot)
| AnnApp (AnnExpr bndr annot) (AnnExpr bndr annot)
| AnnCase (AnnExpr bndr annot) bndr Type [AnnAlt bndr annot]
| AnnLet (AnnBind bndr annot) (AnnExpr bndr annot)
| AnnCast (AnnExpr bndr annot) (annot, Coercion)
| AnnTick (Tickish Id) (AnnExpr bndr annot)
| AnnType Type
| AnnCoercion Coercion
type AnnAlt bndr annot = (AltCon, [bndr], AnnExpr bndr annot)
data AnnBind bndr annot
= AnnNonRec bndr (AnnExpr bndr annot)
| AnnRec [(bndr, AnnExpr bndr annot)]
collectAnnArgs :: AnnExpr b a -> (AnnExpr b a, [AnnExpr b a])
collectAnnArgs :: AnnExpr b a -> (AnnExpr b a, [AnnExpr b a])
collectAnnArgs AnnExpr b a
expr
= AnnExpr b a -> [AnnExpr b a] -> (AnnExpr b a, [AnnExpr b a])
forall bndr annot.
AnnExpr bndr annot
-> [AnnExpr bndr annot]
-> (AnnExpr bndr annot, [AnnExpr bndr annot])
go AnnExpr b a
expr []
where
go :: AnnExpr bndr annot
-> [AnnExpr bndr annot]
-> (AnnExpr bndr annot, [AnnExpr bndr annot])
go (annot
_, AnnApp AnnExpr bndr annot
f AnnExpr bndr annot
a) [AnnExpr bndr annot]
as = AnnExpr bndr annot
-> [AnnExpr bndr annot]
-> (AnnExpr bndr annot, [AnnExpr bndr annot])
go AnnExpr bndr annot
f (AnnExpr bndr annot
aAnnExpr bndr annot -> [AnnExpr bndr annot] -> [AnnExpr bndr annot]
forall a. a -> [a] -> [a]
:[AnnExpr bndr annot]
as)
go AnnExpr bndr annot
e [AnnExpr bndr annot]
as = (AnnExpr bndr annot
e, [AnnExpr bndr annot]
as)
collectAnnArgsTicks :: (Tickish Var -> Bool) -> AnnExpr b a
-> (AnnExpr b a, [AnnExpr b a], [Tickish Var])
collectAnnArgsTicks :: (Tickish CoreBndr -> Bool)
-> AnnExpr b a -> (AnnExpr b a, [AnnExpr b a], [Tickish CoreBndr])
collectAnnArgsTicks Tickish CoreBndr -> Bool
tickishOk AnnExpr b a
expr
= AnnExpr b a
-> [AnnExpr b a]
-> [Tickish CoreBndr]
-> (AnnExpr b a, [AnnExpr b a], [Tickish CoreBndr])
forall bndr annot.
AnnExpr bndr annot
-> [AnnExpr bndr annot]
-> [Tickish CoreBndr]
-> (AnnExpr bndr annot, [AnnExpr bndr annot], [Tickish CoreBndr])
go AnnExpr b a
expr [] []
where
go :: AnnExpr bndr annot
-> [AnnExpr bndr annot]
-> [Tickish CoreBndr]
-> (AnnExpr bndr annot, [AnnExpr bndr annot], [Tickish CoreBndr])
go (annot
_, AnnApp AnnExpr bndr annot
f AnnExpr bndr annot
a) [AnnExpr bndr annot]
as [Tickish CoreBndr]
ts = AnnExpr bndr annot
-> [AnnExpr bndr annot]
-> [Tickish CoreBndr]
-> (AnnExpr bndr annot, [AnnExpr bndr annot], [Tickish CoreBndr])
go AnnExpr bndr annot
f (AnnExpr bndr annot
aAnnExpr bndr annot -> [AnnExpr bndr annot] -> [AnnExpr bndr annot]
forall a. a -> [a] -> [a]
:[AnnExpr bndr annot]
as) [Tickish CoreBndr]
ts
go (annot
_, AnnTick Tickish CoreBndr
t AnnExpr bndr annot
e) [AnnExpr bndr annot]
as [Tickish CoreBndr]
ts | Tickish CoreBndr -> Bool
tickishOk Tickish CoreBndr
t
= AnnExpr bndr annot
-> [AnnExpr bndr annot]
-> [Tickish CoreBndr]
-> (AnnExpr bndr annot, [AnnExpr bndr annot], [Tickish CoreBndr])
go AnnExpr bndr annot
e [AnnExpr bndr annot]
as (Tickish CoreBndr
tTickish CoreBndr -> [Tickish CoreBndr] -> [Tickish CoreBndr]
forall a. a -> [a] -> [a]
:[Tickish CoreBndr]
ts)
go AnnExpr bndr annot
e [AnnExpr bndr annot]
as [Tickish CoreBndr]
ts = (AnnExpr bndr annot
e, [AnnExpr bndr annot]
as, [Tickish CoreBndr] -> [Tickish CoreBndr]
forall a. [a] -> [a]
reverse [Tickish CoreBndr]
ts)
deAnnotate :: AnnExpr bndr annot -> Expr bndr
deAnnotate :: AnnExpr bndr annot -> Expr bndr
deAnnotate (annot
_, AnnExpr' bndr annot
e) = AnnExpr' bndr annot -> Expr bndr
forall bndr annot. AnnExpr' bndr annot -> Expr bndr
deAnnotate' AnnExpr' bndr annot
e
deAnnotate' :: AnnExpr' bndr annot -> Expr bndr
deAnnotate' :: AnnExpr' bndr annot -> Expr bndr
deAnnotate' (AnnType Type
t) = Type -> Expr bndr
forall b. Type -> Expr b
Type Type
t
deAnnotate' (AnnCoercion Coercion
co) = Coercion -> Expr bndr
forall b. Coercion -> Expr b
Coercion Coercion
co
deAnnotate' (AnnVar CoreBndr
v) = CoreBndr -> Expr bndr
forall b. CoreBndr -> Expr b
Var CoreBndr
v
deAnnotate' (AnnLit Literal
lit) = Literal -> Expr bndr
forall b. Literal -> Expr b
Lit Literal
lit
deAnnotate' (AnnLam bndr
binder AnnExpr bndr annot
body) = bndr -> Expr bndr -> Expr bndr
forall b. b -> Expr b -> Expr b
Lam bndr
binder (AnnExpr bndr annot -> Expr bndr
forall bndr annot. AnnExpr bndr annot -> Expr bndr
deAnnotate AnnExpr bndr annot
body)
deAnnotate' (AnnApp AnnExpr bndr annot
fun AnnExpr bndr annot
arg) = Expr bndr -> Expr bndr -> Expr bndr
forall b. Expr b -> Expr b -> Expr b
App (AnnExpr bndr annot -> Expr bndr
forall bndr annot. AnnExpr bndr annot -> Expr bndr
deAnnotate AnnExpr bndr annot
fun) (AnnExpr bndr annot -> Expr bndr
forall bndr annot. AnnExpr bndr annot -> Expr bndr
deAnnotate AnnExpr bndr annot
arg)
deAnnotate' (AnnCast AnnExpr bndr annot
e (annot
_,Coercion
co)) = Expr bndr -> Coercion -> Expr bndr
forall b. Expr b -> Coercion -> Expr b
Cast (AnnExpr bndr annot -> Expr bndr
forall bndr annot. AnnExpr bndr annot -> Expr bndr
deAnnotate AnnExpr bndr annot
e) Coercion
co
deAnnotate' (AnnTick Tickish CoreBndr
tick AnnExpr bndr annot
body) = Tickish CoreBndr -> Expr bndr -> Expr bndr
forall b. Tickish CoreBndr -> Expr b -> Expr b
Tick Tickish CoreBndr
tick (AnnExpr bndr annot -> Expr bndr
forall bndr annot. AnnExpr bndr annot -> Expr bndr
deAnnotate AnnExpr bndr annot
body)
deAnnotate' (AnnLet AnnBind bndr annot
bind AnnExpr bndr annot
body)
= Bind bndr -> Expr bndr -> Expr bndr
forall b. Bind b -> Expr b -> Expr b
Let (AnnBind bndr annot -> Bind bndr
forall b annot. AnnBind b annot -> Bind b
deAnnBind AnnBind bndr annot
bind) (AnnExpr bndr annot -> Expr bndr
forall bndr annot. AnnExpr bndr annot -> Expr bndr
deAnnotate AnnExpr bndr annot
body)
deAnnotate' (AnnCase AnnExpr bndr annot
scrut bndr
v Type
t [AnnAlt bndr annot]
alts)
= Expr bndr -> bndr -> Type -> [Alt bndr] -> Expr bndr
forall b. Expr b -> b -> Type -> [Alt b] -> Expr b
Case (AnnExpr bndr annot -> Expr bndr
forall bndr annot. AnnExpr bndr annot -> Expr bndr
deAnnotate AnnExpr bndr annot
scrut) bndr
v Type
t ((AnnAlt bndr annot -> Alt bndr)
-> [AnnAlt bndr annot] -> [Alt bndr]
forall a b. (a -> b) -> [a] -> [b]
map AnnAlt bndr annot -> Alt bndr
forall bndr annot. AnnAlt bndr annot -> Alt bndr
deAnnAlt [AnnAlt bndr annot]
alts)
deAnnAlt :: AnnAlt bndr annot -> Alt bndr
deAnnAlt :: AnnAlt bndr annot -> Alt bndr
deAnnAlt (AltCon
con,[bndr]
args,AnnExpr bndr annot
rhs) = (AltCon
con,[bndr]
args,AnnExpr bndr annot -> Expr bndr
forall bndr annot. AnnExpr bndr annot -> Expr bndr
deAnnotate AnnExpr bndr annot
rhs)
deAnnBind :: AnnBind b annot -> Bind b
deAnnBind :: AnnBind b annot -> Bind b
deAnnBind (AnnNonRec b
var AnnExpr b annot
rhs) = b -> Expr b -> Bind b
forall b. b -> Expr b -> Bind b
NonRec b
var (AnnExpr b annot -> Expr b
forall bndr annot. AnnExpr bndr annot -> Expr bndr
deAnnotate AnnExpr b annot
rhs)
deAnnBind (AnnRec [(b, AnnExpr b annot)]
pairs) = [(b, Expr b)] -> Bind b
forall b. [(b, Expr b)] -> Bind b
Rec [(b
v,AnnExpr b annot -> Expr b
forall bndr annot. AnnExpr bndr annot -> Expr bndr
deAnnotate AnnExpr b annot
rhs) | (b
v,AnnExpr b annot
rhs) <- [(b, AnnExpr b annot)]
pairs]
collectAnnBndrs :: AnnExpr bndr annot -> ([bndr], AnnExpr bndr annot)
collectAnnBndrs :: AnnExpr bndr annot -> ([bndr], AnnExpr bndr annot)
collectAnnBndrs AnnExpr bndr annot
e
= [bndr] -> AnnExpr bndr annot -> ([bndr], AnnExpr bndr annot)
forall a annot. [a] -> AnnExpr a annot -> ([a], AnnExpr a annot)
collect [] AnnExpr bndr annot
e
where
collect :: [a] -> AnnExpr a annot -> ([a], AnnExpr a annot)
collect [a]
bs (annot
_, AnnLam a
b AnnExpr a annot
body) = [a] -> AnnExpr a annot -> ([a], AnnExpr a annot)
collect (a
ba -> [a] -> [a]
forall a. a -> [a] -> [a]
:[a]
bs) AnnExpr a annot
body
collect [a]
bs AnnExpr a annot
body = ([a] -> [a]
forall a. [a] -> [a]
reverse [a]
bs, AnnExpr a annot
body)
collectNAnnBndrs :: Int -> AnnExpr bndr annot -> ([bndr], AnnExpr bndr annot)
collectNAnnBndrs :: Int -> AnnExpr bndr annot -> ([bndr], AnnExpr bndr annot)
collectNAnnBndrs Int
orig_n AnnExpr bndr annot
e
= Int -> [bndr] -> AnnExpr bndr annot -> ([bndr], AnnExpr bndr annot)
forall t a annot.
(Eq t, Num t) =>
t -> [a] -> AnnExpr a annot -> ([a], AnnExpr a annot)
collect Int
orig_n [] AnnExpr bndr annot
e
where
collect :: t -> [a] -> AnnExpr a annot -> ([a], AnnExpr a annot)
collect t
0 [a]
bs AnnExpr a annot
body = ([a] -> [a]
forall a. [a] -> [a]
reverse [a]
bs, AnnExpr a annot
body)
collect t
n [a]
bs (annot
_, AnnLam a
b AnnExpr a annot
body) = t -> [a] -> AnnExpr a annot -> ([a], AnnExpr a annot)
collect (t
nt -> t -> t
forall a. Num a => a -> a -> a
-t
1) (a
ba -> [a] -> [a]
forall a. a -> [a] -> [a]
:[a]
bs) AnnExpr a annot
body
collect t
_ [a]
_ AnnExpr a annot
_ = String -> SDoc -> ([a], AnnExpr a annot)
forall a. HasCallStack => String -> SDoc -> a
pprPanic String
"collectNBinders" (SDoc -> ([a], AnnExpr a annot)) -> SDoc -> ([a], AnnExpr a annot)
forall a b. (a -> b) -> a -> b
$ Int -> SDoc
int Int
orig_n