{-# 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 con1 :: DataCon
con1) (DataAlt con2 :: 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 _) _ = Ordering
GT
compare _ (DataAlt _) = Ordering
LT
compare (LitAlt l1 :: Literal
l1) (LitAlt l2 :: Literal
l2) = Literal -> Literal -> Ordering
forall a. Ord a => a -> a -> Ordering
compare Literal
l1 Literal
l2
compare (LitAlt _) DEFAULT = Ordering
GT
compare DEFAULT DEFAULT = Ordering
EQ
compare DEFAULT _ = 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 _ = 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 t :: Tickish id
t scope :: TickishScoping
scope = Tickish id -> TickishScoping
forall id. Tickish id -> TickishScoping
tickishScoped Tickish id
t TickishScoping -> TickishScoping -> Bool
`like` TickishScoping
scope
where NoScope like :: TickishScoping -> TickishScoping -> Bool
`like` _ = Bool
True
_ `like` NoScope = Bool
False
SoftScope `like` _ = Bool
True
_ `like` SoftScope = Bool
False
CostCentreScope `like` _ = Bool
True
tickishFloatable :: Tickish id -> Bool
tickishFloatable :: Tickish id -> Bool
tickishFloatable t :: 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 _ = Bool
False
mkNoCount :: Tickish id -> Tickish id
mkNoCount :: Tickish id -> Tickish id
mkNoCount n :: 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 "mkNoCount: Cannot split!"
mkNoCount n :: Tickish id
n@ProfNote{} = Tickish id
n {profNoteCount :: Bool
profNoteCount = Bool
False}
mkNoCount _ = String -> Tickish id
forall a. String -> a
panic "mkNoCount: Undefined split!"
mkNoScope :: Tickish id -> Tickish id
mkNoScope :: Tickish id -> Tickish id
mkNoScope n :: 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 "mkNoScope: Cannot split!"
mkNoScope n :: Tickish id
n@ProfNote{} = Tickish id
n {profNoteScope :: Bool
profNoteScope = Bool
False}
mkNoScope _ = String -> Tickish id
forall a. String -> a
panic "mkNoScope: Undefined split!"
tickishIsCode :: Tickish id -> Bool
tickishIsCode :: Tickish id -> Bool
tickishIsCode SourceNote{} = Bool
False
tickishIsCode _tickish :: 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 sp1 :: RealSrcSpan
sp1 n1 :: String
n1) (SourceNote sp2 :: RealSrcSpan
sp2 n2 :: 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 t1 :: Tickish b
t1 t2 :: 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 = Bool
True
isOrphan _ = Bool
False
notOrphan :: IsOrphan -> Bool
notOrphan :: IsOrphan -> Bool
notOrphan NotOrphan{} = Bool
True
notOrphan _ = Bool
False
chooseOrphanAnchor :: NameSet -> IsOrphan
chooseOrphanAnchor :: NameSet -> IsOrphan
chooseOrphanAnchor local_names :: 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_ bh :: BinHandle
bh IsOrphan = BinHandle -> Word8 -> IO ()
putByte BinHandle
bh 0
put_ bh :: BinHandle
bh (NotOrphan n :: OccName
n) = do
BinHandle -> Word8 -> IO ()
putByte BinHandle
bh 1
BinHandle -> OccName -> IO ()
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh OccName
n
get :: BinHandle -> IO IsOrphan
get bh :: BinHandle
bh = do
Word8
h <- BinHandle -> IO Word8
getByte BinHandle
bh
case Word8
h of
0 -> IsOrphan -> IO IsOrphan
forall (m :: * -> *) a. Monad m => a -> m a
return IsOrphan
IsOrphan
_ -> 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 rules :: RuleBase
rules vis_orphs :: [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 _ = 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 nm :: Name
nm ru :: 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 InlineCompulsory = Bool
True
isStableSource InlineStable = Bool
True
isStableSource 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 _
= Maybe CoreExpr
forall a. Maybe a
Nothing
otherCons :: Unfolding -> [AltCon]
otherCons :: Unfolding -> [AltCon]
otherCons (OtherCon cons :: [AltCon]
cons) = [AltCon]
cons
otherCons _ = []
isValueUnfolding :: Unfolding -> Bool
isValueUnfolding :: Unfolding -> Bool
isValueUnfolding (CoreUnfolding { uf_is_value :: Unfolding -> Bool
uf_is_value = Bool
is_evald }) = Bool
is_evald
isValueUnfolding _ = Bool
False
isEvaldUnfolding :: Unfolding -> Bool
isEvaldUnfolding :: Unfolding -> Bool
isEvaldUnfolding (OtherCon _) = Bool
True
isEvaldUnfolding (CoreUnfolding { uf_is_value :: Unfolding -> Bool
uf_is_value = Bool
is_evald }) = Bool
is_evald
isEvaldUnfolding _ = Bool
False
isConLikeUnfolding :: Unfolding -> Bool
isConLikeUnfolding :: Unfolding -> Bool
isConLikeUnfolding (OtherCon _) = Bool
True
isConLikeUnfolding (CoreUnfolding { uf_is_conlike :: Unfolding -> Bool
uf_is_conlike = Bool
con }) = Bool
con
isConLikeUnfolding _ = 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 _ = Bool
False
isExpandableUnfolding :: Unfolding -> Bool
isExpandableUnfolding :: Unfolding -> Bool
isExpandableUnfolding (CoreUnfolding { uf_expandable :: Unfolding -> Bool
uf_expandable = Bool
is_expable }) = Bool
is_expable
isExpandableUnfolding _ = 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 _ = 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 _ = 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 _ = Bool
False
hasSomeUnfolding :: Unfolding -> Bool
hasSomeUnfolding :: Unfolding -> Bool
hasSomeUnfolding NoUnfolding = Bool
False
hasSomeUnfolding BootUnfolding = Bool
False
hasSomeUnfolding _ = Bool
True
isBootUnfolding :: Unfolding -> Bool
isBootUnfolding :: Unfolding -> Bool
isBootUnfolding BootUnfolding = Bool
True
isBootUnfolding _ = Bool
False
neverUnfoldGuidance :: UnfoldingGuidance -> Bool
neverUnfoldGuidance :: UnfoldingGuidance -> Bool
neverUnfoldGuidance UnfNever = Bool
True
neverUnfoldGuidance _ = Bool
False
isFragileUnfolding :: Unfolding -> Bool
isFragileUnfolding :: Unfolding -> Bool
isFragileUnfolding (CoreUnfolding {}) = Bool
True
isFragileUnfolding (DFunUnfolding {}) = Bool
True
isFragileUnfolding _ = 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 _ = Bool
False
instance Outputable AltCon where
ppr :: AltCon -> SDoc
ppr (DataAlt dc :: DataCon
dc) = DataCon -> SDoc
forall a. Outputable a => a -> SDoc
ppr DataCon
dc
ppr (LitAlt lit :: Literal
lit) = Literal -> SDoc
forall a. Outputable a => a -> SDoc
ppr Literal
lit
ppr DEFAULT = String -> SDoc
text "__DEFAULT"
cmpAlt :: (AltCon, a, b) -> (AltCon, a, b) -> Ordering
cmpAlt :: (AltCon, a, b) -> (AltCon, a, b) -> Ordering
cmpAlt (con1 :: AltCon
con1, _, _) (con2 :: AltCon
con2, _, _) = 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 a1 :: (AltCon, a, b)
a1 a2 :: (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 DEFAULT DEFAULT = Ordering
EQ
cmpAltCon DEFAULT _ = Ordering
LT
cmpAltCon (DataAlt d1 :: DataCon
d1) (DataAlt d2 :: 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 _) DEFAULT = Ordering
GT
cmpAltCon (LitAlt l1 :: Literal
l1) (LitAlt l2 :: Literal
l2) = Literal
l1 Literal -> Literal -> Ordering
forall a. Ord a => a -> a -> Ordering
`compare` Literal
l2
cmpAltCon (LitAlt _) DEFAULT = Ordering
GT
cmpAltCon con1 :: AltCon
con1 con2 :: 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 b :: CoreBndr
b l :: b
l) = Char -> SDoc
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 '>'
deTagExpr :: TaggedExpr t -> CoreExpr
deTagExpr :: TaggedExpr t -> CoreExpr
deTagExpr (Var v :: CoreBndr
v) = CoreBndr -> CoreExpr
forall b. CoreBndr -> Expr b
Var CoreBndr
v
deTagExpr (Lit l :: Literal
l) = Literal -> CoreExpr
forall b. Literal -> Expr b
Lit Literal
l
deTagExpr (Type ty :: Type
ty) = Type -> CoreExpr
forall b. Type -> Expr b
Type Type
ty
deTagExpr (Coercion co :: Coercion
co) = Coercion -> CoreExpr
forall b. Coercion -> Expr b
Coercion Coercion
co
deTagExpr (App e1 :: TaggedExpr t
e1 e2 :: 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 b :: CoreBndr
b _) e :: 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 :: Bind (TaggedBndr t)
bind body :: 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 e :: TaggedExpr t
e (TB b :: CoreBndr
b _) ty :: Type
ty alts :: [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 t :: Tickish CoreBndr
t e :: 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 e :: TaggedExpr t
e co :: 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 b :: CoreBndr
b _) rhs :: 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 prs :: [(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 b :: CoreBndr
b _, rhs :: Expr (TaggedBndr t)
rhs) <- [(TaggedBndr t, Expr (TaggedBndr t))]
prs]
deTagAlt :: TaggedAlt t -> CoreAlt
deTagAlt :: TaggedAlt t -> Alt CoreBndr
deTagAlt (con :: AltCon
con, bndrs :: [TaggedBndr t]
bndrs, rhs :: Expr (TaggedBndr t)
rhs) = (AltCon
con, [CoreBndr
b | TB b :: CoreBndr
b _ <- [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 f :: Expr b
f args :: [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 f :: Expr b
f args :: [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' (\ e :: Expr b
e a :: 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 f :: Expr b
f vars :: [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' (\ e :: Expr b
e a :: 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 con :: DataCon
con args :: [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 f :: Expr b
f args :: [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' (\ e :: Expr b
e a :: 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 con :: DataCon
con tys :: [Type]
tys arg_ids :: [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 ty :: Type
ty
| Just co :: 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 dflags :: DynFlags
dflags n :: 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 dflags :: DynFlags
dflags n :: 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 dflags :: DynFlags
dflags w :: 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 dflags :: DynFlags
dflags w :: 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 w :: 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 w :: 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 c :: Char
c = Literal -> Expr b
forall b. Literal -> Expr b
Lit (Char -> Literal
mkLitChar Char
c)
mkStringLit :: String -> Expr b
mkStringLit s :: 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 f :: Rational
f = Literal -> Expr b
forall b. Literal -> Expr b
Lit (Rational -> Literal
mkLitFloat Rational
f)
mkFloatLitFloat :: Float -> Expr b
mkFloatLitFloat f :: 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 d :: Rational
d = Literal -> Expr b
forall b. Literal -> Expr b
Lit (Rational -> Literal
mkLitDouble Rational
d)
mkDoubleLitDouble :: Double -> Expr b
mkDoubleLitDouble d :: 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 binders :: [b]
binders body :: 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 binds :: [Bind b]
binds body :: 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 []) body :: Expr b
body = Expr b
body
mkLet bind :: Bind b
bind body :: 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
b rhs :: Expr b
rhs body :: 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 [] body :: Expr b
body = Expr b
body
mkLetRec bs :: [(b, Expr b)]
bs body :: 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 tv :: CoreBndr
tv ty :: 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 cv :: CoreBndr
cv co :: 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 v :: 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 vs :: [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 fun_ty :: Type
fun_ty arg :: 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 ty :: Type
ty) = Type
ty
exprToType _bad :: CoreExpr
_bad = String -> SDoc -> Type
forall a. HasCallStack => String -> SDoc -> a
pprPanic "exprToType" SDoc
empty
exprToCoercion_maybe :: CoreExpr -> Maybe Coercion
exprToCoercion_maybe :: CoreExpr -> Maybe Coercion
exprToCoercion_maybe (Coercion co :: Coercion
co) = Coercion -> Maybe Coercion
forall a. a -> Maybe a
Just Coercion
co
exprToCoercion_maybe _ = Maybe Coercion
forall a. Maybe a
Nothing
bindersOf :: Bind b -> [b]
bindersOf :: Bind b -> [b]
bindersOf (NonRec binder :: b
binder _) = [b
binder]
bindersOf (Rec pairs :: [(b, Expr b)]
pairs) = [b
binder | (binder :: b
binder, _) <- [(b, Expr b)]
pairs]
bindersOfBinds :: [Bind b] -> [b]
bindersOfBinds :: [Bind b] -> [b]
bindersOfBinds binds :: [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 _ rhs :: Expr b
rhs) = [Expr b
rhs]
rhssOfBind (Rec pairs :: [(b, Expr b)]
pairs) = [Expr b
rhs | (_,rhs :: Expr b
rhs) <- [(b, Expr b)]
pairs]
rhssOfAlts :: [Alt b] -> [Expr b]
rhssOfAlts :: [Alt b] -> [Expr b]
rhssOfAlts alts :: [Alt b]
alts = [Expr b
e | (_,_,e :: Expr b
e) <- [Alt b]
alts]
flattenBinds :: [Bind b] -> [(b, Expr b)]
flattenBinds :: [Bind b] -> [(b, Expr b)]
flattenBinds (NonRec b :: b
b r :: Expr b
r : binds :: [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 prs1 :: [(b, Expr b)]
prs1 : binds :: [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 :: 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 bs :: [a]
bs (Lam b :: a
b e :: 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 bs :: [a]
bs e :: Expr a
e = ([a] -> [a]
forall a. [a] -> [a]
reverse [a]
bs, Expr a
e)
collectTyBinders :: CoreExpr -> ([CoreBndr], CoreExpr)
collectTyBinders expr :: CoreExpr
expr
= [CoreBndr] -> CoreExpr -> ([CoreBndr], CoreExpr)
go [] CoreExpr
expr
where
go :: [CoreBndr] -> CoreExpr -> ([CoreBndr], CoreExpr)
go tvs :: [CoreBndr]
tvs (Lam b :: CoreBndr
b e :: 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 tvs :: [CoreBndr]
tvs e :: CoreExpr
e = ([CoreBndr] -> [CoreBndr]
forall a. [a] -> [a]
reverse [CoreBndr]
tvs, CoreExpr
e)
collectValBinders :: CoreExpr -> ([CoreBndr], CoreExpr)
collectValBinders expr :: CoreExpr
expr
= [CoreBndr] -> CoreExpr -> ([CoreBndr], CoreExpr)
go [] CoreExpr
expr
where
go :: [CoreBndr] -> CoreExpr -> ([CoreBndr], CoreExpr)
go ids :: [CoreBndr]
ids (Lam b :: CoreBndr
b e :: 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 ids :: [CoreBndr]
ids body :: CoreExpr
body = ([CoreBndr] -> [CoreBndr]
forall a. [a] -> [a]
reverse [CoreBndr]
ids, CoreExpr
body)
collectTyAndValBinders :: CoreExpr -> ([CoreBndr], [CoreBndr], CoreExpr)
collectTyAndValBinders expr :: CoreExpr
expr
= ([CoreBndr]
tvs, [CoreBndr]
ids, CoreExpr
body)
where
(tvs :: [CoreBndr]
tvs, body1 :: CoreExpr
body1) = CoreExpr -> ([CoreBndr], CoreExpr)
collectTyBinders CoreExpr
expr
(ids :: [CoreBndr]
ids, body :: CoreExpr
body) = CoreExpr -> ([CoreBndr], CoreExpr)
collectValBinders CoreExpr
body1
collectNBinders :: Int -> Expr b -> ([b], Expr b)
collectNBinders orig_n :: Int
orig_n orig_expr :: 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 0 bs :: [a]
bs expr :: Expr a
expr = ([a] -> [a]
forall a. [a] -> [a]
reverse [a]
bs, Expr a
expr)
go n :: t
n bs :: [a]
bs (Lam b :: a
b e :: Expr a
e) = t -> [a] -> Expr a -> ([a], Expr a)
go (t
nt -> t -> t
forall a. Num a => a -> a -> a
-1) (a
ba -> [a] -> [a]
forall a. a -> [a] -> [a]
:[a]
bs) Expr a
e
go _ _ _ = String -> SDoc -> ([a], Expr a)
forall a. HasCallStack => String -> SDoc -> a
pprPanic "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 :: 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 f :: Expr b
f a :: Expr b
a) as :: [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 e :: Expr b
e as :: [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 _ e :: Expr a
e) = Word -> Expr a -> Maybe (Expr a)
forall a. Word -> Expr a -> Maybe (Expr a)
stripNArgs Word
n Expr a
e
stripNArgs n :: Word
n (Cast f :: Expr a
f _) = Word -> Expr a -> Maybe (Expr a)
forall a. Word -> Expr a -> Maybe (Expr a)
stripNArgs Word
n Expr a
f
stripNArgs 0 e :: Expr a
e = Expr a -> Maybe (Expr a)
forall a. a -> Maybe a
Just Expr a
e
stripNArgs n :: Word
n (App f :: Expr a
f _) = 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
- 1) Expr a
f
stripNArgs _ _ = 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 skipTick :: Tickish CoreBndr -> Bool
skipTick expr :: 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 f :: Expr b
f a :: Expr b
a) as :: [Expr b]
as ts :: [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 t :: Tickish CoreBndr
t e :: Expr b
e) as :: [Expr b]
as ts :: [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 e :: Expr b
e as :: [Expr b]
as ts :: [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 e :: 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 _ = Bool
False
isCoArg :: Expr b -> Bool
isCoArg :: Expr b -> Bool
isCoArg (Coercion {}) = Bool
True
isCoArg _ = Bool
False
isTypeArg :: Expr b -> Bool
isTypeArg :: Expr b -> Bool
isTypeArg (Type {}) = Bool
True
isTypeArg _ = 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 expr :: 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 (_, AnnApp f :: AnnExpr bndr annot
f a :: AnnExpr bndr annot
a) as :: [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 e :: AnnExpr bndr annot
e as :: [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 tickishOk :: Tickish CoreBndr -> Bool
tickishOk expr :: 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 (_, AnnApp f :: AnnExpr bndr annot
f a :: AnnExpr bndr annot
a) as :: [AnnExpr bndr annot]
as ts :: [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 (_, AnnTick t :: Tickish CoreBndr
t e :: AnnExpr bndr annot
e) as :: [AnnExpr bndr annot]
as ts :: [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 e :: AnnExpr bndr annot
e as :: [AnnExpr bndr annot]
as ts :: [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 (_, e :: 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 t :: Type
t) = Type -> Expr bndr
forall b. Type -> Expr b
Type Type
t
deAnnotate' (AnnCoercion co :: Coercion
co) = Coercion -> Expr bndr
forall b. Coercion -> Expr b
Coercion Coercion
co
deAnnotate' (AnnVar v :: CoreBndr
v) = CoreBndr -> Expr bndr
forall b. CoreBndr -> Expr b
Var CoreBndr
v
deAnnotate' (AnnLit lit :: Literal
lit) = Literal -> Expr bndr
forall b. Literal -> Expr b
Lit Literal
lit
deAnnotate' (AnnLam binder :: bndr
binder body :: 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 fun :: AnnExpr bndr annot
fun arg :: 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 e :: AnnExpr bndr annot
e (_,co :: 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 tick :: Tickish CoreBndr
tick body :: 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 bind :: AnnBind bndr annot
bind body :: 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 scrut :: AnnExpr bndr annot
scrut v :: bndr
v t :: Type
t alts :: [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 (con :: AltCon
con,args :: [bndr]
args,rhs :: 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 var :: b
var rhs :: 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 pairs :: [(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) | (v :: b
v,rhs :: 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 e :: 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 bs :: [a]
bs (_, AnnLam b :: a
b body :: 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 bs :: [a]
bs body :: 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 orig_n :: Int
orig_n e :: 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 0 bs :: [a]
bs body :: AnnExpr a annot
body = ([a] -> [a]
forall a. [a] -> [a]
reverse [a]
bs, AnnExpr a annot
body)
collect n :: t
n bs :: [a]
bs (_, AnnLam b :: a
b body :: 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
-1) (a
ba -> [a] -> [a]
forall a. a -> [a] -> [a]
:[a]
bs) AnnExpr a annot
body
collect _ _ _ = String -> SDoc -> ([a], AnnExpr a annot)
forall a. HasCallStack => String -> SDoc -> a
pprPanic "collectNBinders" (SDoc -> ([a], AnnExpr a annot)) -> SDoc -> ([a], AnnExpr a annot)
forall a b. (a -> b) -> a -> b
$ Int -> SDoc
int Int
orig_n