{-# LANGUAGE CPP, DeriveDataTypeable, FlexibleContexts #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE BangPatterns #-}
{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}
{-# OPTIONS_GHC -Wno-incomplete-record-updates #-}
module GHC.Core (
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, hasCoreUnfolding, 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(..), RuleOpts(..), mkRuleEnv, emptyRuleEnv,
ruleArity, ruleName, ruleIdName, ruleActivation,
setRuleIdName, ruleModule,
isBuiltinRule, isLocalRule, isAutoRule,
) where
#include "HsVersions.h"
import GHC.Prelude
import GHC.Platform
import GHC.Types.CostCentre
import GHC.Types.Var.Env( InScopeSet )
import GHC.Types.Var
import GHC.Core.Type
import GHC.Core.Coercion
import GHC.Types.Name
import GHC.Types.Name.Set
import GHC.Types.Name.Env( NameEnv, emptyNameEnv )
import GHC.Types.Literal
import GHC.Core.DataCon
import GHC.Unit.Module
import GHC.Types.Basic
import GHC.Utils.Outputable
import GHC.Utils.Misc
import GHC.Types.Unique.Set
import GHC.Types.SrcLoc ( RealSrcSpan, containsSpan )
import GHC.Utils.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.
ConTag -> (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 =>
ConTag -> (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. ConTag -> (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. ConTag -> (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 :: ConTag -> (forall d. Data d => d -> u) -> Expr b -> u
$cgmapQi :: forall b u.
Data b =>
ConTag -> (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)
External instance of the constraint type forall a. Data a => Data [a]
Evidence bound by a type signature of the constraint type Data b
Instance of class: Data of the constraint type Data AltCon
External instance of the constraint type forall a. Data a => Data [a]
Evidence bound by a type signature of the constraint type Data b
Instance of class: Data of the constraint type Data AltCon
External instance of the constraint type forall a b c. (Data a, Data b, Data c) => Data (a, b, c)
Evidence bound by a type signature of the constraint type Typeable t
External instance of the constraint type Data Coercion
External instance of the constraint type Data Type
External instance of the constraint type forall a b c. (Data a, Data b, Data c) => Data (a, b, c)
Instance of class: Data of the constraint type Data AltCon
External instance of the constraint type forall a. Data a => Data [a]
Evidence bound by a type signature of the constraint type Data b
Instance of class: Data of the constraint type forall b. Data b => Data (Expr b)
Evidence bound by a type signature of the constraint type Data b
Instance of class: Data of the constraint type forall b. Data b => Data (Expr b)
Evidence bound by a type signature of the constraint type Data b
External instance of the constraint type Data Id
External instance of the constraint type Data Coercion
External instance of the constraint type Data Coercion
External instance of the constraint type Data Type
External instance of the constraint type Data Type
External instance of the constraint type forall a b c. (Data a, Data b, Data c) => Data (a, b, c)
Instance of class: Data of the constraint type Data AltCon
External instance of the constraint type forall a. Data a => Data [a]
Evidence bound by a type signature of the constraint type Data b
Instance of class: Data of the constraint type forall b. Data b => Data (Expr b)
Evidence bound by a type signature of the constraint type Data b
External instance of the constraint type forall a. Data a => Data [a]
Instance of class: Data of the constraint type forall b. Data b => Data (Expr b)
Evidence bound by a type signature of the constraint type Data b
External instance of the constraint type Data Literal
External instance of the constraint type Data Id
External instance of the constraint type Data Id
External instance of the constraint type forall a. Data a => Typeable a
Evidence bound by a type signature of the constraint type Data b
External instance of the constraint type forall a. Data a => Typeable a
External instance of the constraint type forall a. Data a => Typeable a
Evidence bound by a type signature of the constraint type Data b
Instance of class: Data of the constraint type Data AltCon
Instance of class: Data of the constraint type forall id. Data id => Data (Tickish id)
Instance of class: Data of the constraint type forall b. Data b => Data (Bind b)
Instance of class: Data of the constraint type forall b. Data b => Data (Expr b)
Evidence bound by a type signature of the constraint type Data 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
External instance of the constraint type Eq Literal
External instance of the constraint type Eq DataCon
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.
ConTag -> (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. ConTag -> (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. ConTag -> (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 :: ConTag -> (forall d. Data d => d -> u) -> AltCon -> u
$cgmapQi :: forall u. ConTag -> (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
External instance of the constraint type Data DataCon
External instance of the constraint type Data Literal
Data)
instance Ord AltCon where
compare :: AltCon -> AltCon -> Ordering
compare (DataAlt DataCon
con1) (DataAlt DataCon
con2) =
ASSERT( dataConTyCon con1 == dataConTyCon con2 )
ConTag -> ConTag -> Ordering
forall a. Ord a => a -> a -> Ordering
External instance of the constraint type Ord ConTag
compare (DataCon -> ConTag
dataConTag DataCon
con1) (DataCon -> ConTag
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
External instance of the constraint type Ord Literal
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.
ConTag -> (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 =>
ConTag -> (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. ConTag -> (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. ConTag -> (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 :: ConTag -> (forall d. Data d => d -> u) -> Bind b -> u
$cgmapQi :: forall b u.
Data b =>
ConTag -> (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)
External instance of the constraint type forall a b. (Data a, Data b) => Data (a, b)
Evidence bound by a type signature of the constraint type Typeable t
External instance of the constraint type forall a b. (Data a, Data b) => Data (a, b)
Evidence bound by a type signature of the constraint type Data b
Instance of class: Data of the constraint type forall b. Data b => Data (Expr b)
Evidence bound by a type signature of the constraint type Data b
Instance of class: Data of the constraint type forall b. Data b => Data (Expr b)
Evidence bound by a type signature of the constraint type Data b
External instance of the constraint type forall a b. (Data a, Data b) => Data (a, b)
Evidence bound by a type signature of the constraint type Data b
Instance of class: Data of the constraint type forall b. Data b => Data (Expr b)
Evidence bound by a type signature of the constraint type Data b
Instance of class: Data of the constraint type forall b. Data b => Data (Expr b)
Evidence bound by a type signature of the constraint type Data b
External instance of the constraint type forall a. Data a => Typeable a
Evidence bound by a type signature of the constraint type Data b
External instance of the constraint type forall a. Data a => Data [a]
External instance of the constraint type forall a. Data a => Typeable a
Evidence bound by a type signature of the constraint type Data b
External instance of the constraint type forall a. Data a => Typeable a
Evidence bound by a type signature of the constraint type Data b
Instance of class: Data of the constraint type forall b. Data b => Data (Expr 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 -> ConTag
tickId :: !Int
}
| Breakpoint
{ Tickish id -> ConTag
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
External instance of the constraint type Eq Char
External instance of the constraint type Eq (GenUnit UnitId)
External instance of the constraint type Eq Char
External instance of the constraint type Eq RealSrcSpan
External instance of the constraint type forall a. Eq a => Eq [a]
External instance of the constraint type Eq ConTag
External instance of the constraint type Eq ConTag
External instance of the constraint type Eq (GenUnit UnitId)
External instance of the constraint type forall unit. Eq unit => Eq (GenModule unit)
External instance of the constraint type Eq Bool
External instance of the constraint type Eq Bool
External instance of the constraint type Eq CostCentre
Evidence bound by a type signature of the constraint type Eq id
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
External instance of the constraint type Ord Char
External instance of the constraint type Ord (GenUnit UnitId)
External instance of the constraint type Ord Char
External instance of the constraint type Ord RealSrcSpan
External instance of the constraint type forall a. Ord a => Ord [a]
External instance of the constraint type Ord (GenUnit UnitId)
External instance of the constraint type forall unit. Ord unit => Ord (GenModule unit)
External instance of the constraint type Ord Bool
External instance of the constraint type Ord Bool
External instance of the constraint type Ord CostCentre
Instance of class: Eq of the constraint type forall id. Eq id => Eq (Tickish id)
External instance of the constraint type forall a. Ord a => Eq a
Evidence bound by a type signature of the constraint type Ord id
External instance of the constraint type Ord ConTag
External instance of the constraint type forall a. Ord a => Eq a
External instance of the constraint type forall a. Ord a => Eq a
Evidence bound by a type signature of the constraint type Ord id
Evidence bound by a type signature of the constraint type Ord id
Instance of class: Eq of the constraint type forall id. Eq 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.
ConTag -> (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 =>
ConTag -> (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. ConTag -> (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. ConTag -> (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 :: ConTag -> (forall d. Data d => d -> u) -> Tickish id -> u
$cgmapQi :: forall id u.
Data id =>
ConTag -> (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)
External instance of the constraint type Data Char
External instance of the constraint type Data (GenUnit UnitId)
Evidence bound by a type signature of the constraint type Typeable t
External instance of the constraint type Data Char
External instance of the constraint type Data (GenUnit UnitId)
External instance of the constraint type Data ConTag
External instance of the constraint type Data Bool
External instance of the constraint type Data RealSrcSpan
External instance of the constraint type Data Char
External instance of the constraint type Data (GenUnit UnitId)
External instance of the constraint type forall unit. Data unit => Data (GenModule unit)
External instance of the constraint type Data ConTag
External instance of the constraint type Data ConTag
External instance of the constraint type Data CostCentre
External instance of the constraint type Data Bool
External instance of the constraint type Data Bool
External instance of the constraint type forall a. Data a => Typeable a
Evidence bound by a type signature of the constraint type Data id
External instance of the constraint type forall a. Data a => Data [a]
External instance of the constraint type forall a. Data a => Typeable a
Evidence bound by a type signature of the constraint type Data id
External instance of the constraint type forall a. Data a => Typeable a
Evidence bound by a type signature of the constraint type Data 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
Instance of class: Eq of the constraint type Eq TickishScoping
== 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
External instance of the constraint type forall a. Eq a => Eq [a]
External instance of the constraint type Eq Char
== String
n2
tickishContains Tickish b
t1 Tickish b
t2
= Tickish b
t1 Tickish b -> Tickish b -> Bool
forall a. Eq a => a -> a -> Bool
Instance of class: Eq of the constraint type forall id. Eq id => Eq (Tickish id)
Evidence bound by a type signature of the constraint type Eq b
== 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.
ConTag -> (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. ConTag -> (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. ConTag -> (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 :: ConTag -> (forall d. Data d => d -> u) -> IsOrphan -> u
$cgmapQi :: forall u. ConTag -> (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
External instance of the constraint type Data OccName
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
External instance of the constraint type Ord OccName
External instance of the constraint type Foldable []
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 ()
External instance of the constraint type Binary OccName
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
External instance of the constraint type Monad IO
return IsOrphan
IsOrphan
Word8
_ -> do
OccName
n <- BinHandle -> IO OccName
forall a. Binary a => BinHandle -> IO a
External instance of the constraint type Binary OccName
get BinHandle
bh
IsOrphan -> IO IsOrphan
forall (m :: * -> *) a. Monad m => a -> m a
External instance of the constraint type Monad IO
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 -> [Id]
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 -> ConTag
ru_nargs :: Int,
CoreRule -> RuleFun
ru_try :: RuleFun
}
data RuleOpts = RuleOpts
{ RuleOpts -> Platform
roPlatform :: !Platform
, RuleOpts -> Bool
roNumConstantFolding :: !Bool
, RuleOpts -> Bool
roExcessRationalPrecision :: !Bool
}
type RuleFun = RuleOpts -> 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 -> ConTag
ruleArity (BuiltinRule {ru_nargs :: CoreRule -> ConTag
ru_nargs = ConTag
n}) = ConTag
n
ruleArity (Rule {ru_args :: CoreRule -> [CoreExpr]
ru_args = [CoreExpr]
args}) = [CoreExpr] -> ConTag
forall (t :: * -> *) a. Foldable t => t a -> ConTag
External instance of the constraint type Foldable []
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 -> [Id]
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 -> ConTag
ug_arity :: Arity,
UnfoldingGuidance -> Bool
ug_unsat_ok :: Bool,
UnfoldingGuidance -> Bool
ug_boring_ok :: Bool
}
| UnfIfGoodArgs {
UnfoldingGuidance -> [ConTag]
ug_args :: [Int],
UnfoldingGuidance -> ConTag
ug_size :: Int,
UnfoldingGuidance -> ConTag
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
External instance of the constraint type Eq Bool
External instance of the constraint type Eq ConTag
External instance of the constraint type forall a. Eq a => Eq [a]
External instance of the constraint type Eq ConTag
External instance of the constraint type Eq 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 -> [Id]
df_bndrs = [Id]
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 ([Id] -> CoreExpr -> CoreExpr
forall b. [b] -> Expr b -> Expr b
mkLams [Id]
bndrs (CoreExpr -> [CoreExpr] -> CoreExpr
forall b. Expr b -> [Expr b] -> Expr b
mkApps (Id -> CoreExpr
forall b. Id -> Expr b
Var (DataCon -> Id
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
hasCoreUnfolding :: Unfolding -> Bool
hasCoreUnfolding :: Unfolding -> Bool
hasCoreUnfolding (CoreUnfolding {}) = Bool
True
hasCoreUnfolding (DFunUnfolding {}) = Bool
True
hasCoreUnfolding 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
External instance of the constraint type Outputable DataCon
ppr DataCon
dc
ppr (LitAlt Literal
lit) = Literal -> SDoc
forall a. Outputable a => a -> SDoc
External instance of the constraint type Outputable Literal
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
External instance of the constraint type Eq Ordering
== 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 -> ConTag
dataConTag DataCon
d1 ConTag -> ConTag -> Ordering
forall a. Ord a => a -> a -> Ordering
External instance of the constraint type Ord ConTag
`compare` DataCon -> ConTag
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
External instance of the constraint type Ord Literal
`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 Id
b b
l) = Char -> SDoc
char Char
'<' SDoc -> SDoc -> SDoc
<> Id -> SDoc
forall a. Outputable a => a -> SDoc
External instance of the constraint type Outputable Id
ppr Id
b SDoc -> SDoc -> SDoc
<> SDoc
comma SDoc -> SDoc -> SDoc
<> b -> SDoc
forall a. Outputable a => a -> SDoc
Evidence bound by a type signature of the constraint type Outputable b
ppr b
l SDoc -> SDoc -> SDoc
<> Char -> SDoc
char Char
'>'
deTagExpr :: TaggedExpr t -> CoreExpr
deTagExpr :: TaggedExpr t -> CoreExpr
deTagExpr (Var Id
v) = Id -> CoreExpr
forall b. Id -> Expr b
Var Id
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 Id
b t
_) TaggedExpr t
e) = Id -> CoreExpr -> CoreExpr
forall b. b -> Expr b -> Expr b
Lam Id
b (TaggedExpr t -> CoreExpr
forall t. TaggedExpr t -> CoreExpr
deTagExpr TaggedExpr t
e)
deTagExpr (Let Bind (TaggedBndr t)
bind TaggedExpr t
body) = Bind Id -> CoreExpr -> CoreExpr
forall b. Bind b -> Expr b -> Expr b
Let (Bind (TaggedBndr t) -> Bind Id
forall t. TaggedBind t -> Bind Id
deTagBind Bind (TaggedBndr t)
bind) (TaggedExpr t -> CoreExpr
forall t. TaggedExpr t -> CoreExpr
deTagExpr TaggedExpr t
body)
deTagExpr (Case TaggedExpr t
e (TB Id
b t
_) Type
ty [Alt (TaggedBndr t)]
alts) = CoreExpr -> Id -> Type -> [Alt Id] -> CoreExpr
forall b. Expr b -> b -> Type -> [Alt b] -> Expr b
Case (TaggedExpr t -> CoreExpr
forall t. TaggedExpr t -> CoreExpr
deTagExpr TaggedExpr t
e) Id
b Type
ty ((Alt (TaggedBndr t) -> Alt Id) -> [Alt (TaggedBndr t)] -> [Alt Id]
forall a b. (a -> b) -> [a] -> [b]
map Alt (TaggedBndr t) -> Alt Id
forall t. TaggedAlt t -> Alt Id
deTagAlt [Alt (TaggedBndr t)]
alts)
deTagExpr (Tick Tickish Id
t TaggedExpr t
e) = Tickish Id -> CoreExpr -> CoreExpr
forall b. Tickish Id -> Expr b -> Expr b
Tick Tickish Id
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 Id
deTagBind (NonRec (TB Id
b t
_) Expr (TaggedBndr t)
rhs) = Id -> CoreExpr -> Bind Id
forall b. b -> Expr b -> Bind b
NonRec Id
b (Expr (TaggedBndr t) -> CoreExpr
forall t. TaggedExpr t -> CoreExpr
deTagExpr Expr (TaggedBndr t)
rhs)
deTagBind (Rec [(TaggedBndr t, Expr (TaggedBndr t))]
prs) = [(Id, CoreExpr)] -> Bind Id
forall b. [(b, Expr b)] -> Bind b
Rec [(Id
b, Expr (TaggedBndr t) -> CoreExpr
forall t. TaggedExpr t -> CoreExpr
deTagExpr Expr (TaggedBndr t)
rhs) | (TB Id
b t
_, Expr (TaggedBndr t)
rhs) <- [(TaggedBndr t, Expr (TaggedBndr t))]
prs]
deTagAlt :: TaggedAlt t -> CoreAlt
deTagAlt :: TaggedAlt t -> Alt Id
deTagAlt (AltCon
con, [TaggedBndr t]
bndrs, Expr (TaggedBndr t)
rhs) = (AltCon
con, [Id
b | TB Id
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
External instance of the constraint type Foldable []
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
External instance of the constraint type Foldable []
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 -> [Id] -> Expr b
mkVarApps Expr b
f [Id]
vars = (Expr b -> Id -> Expr b) -> Expr b -> [Id] -> Expr b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
External instance of the constraint type Foldable []
foldl' (\ Expr b
e Id
a -> Expr b -> Expr b -> Expr b
forall b. Expr b -> Expr b -> Expr b
App Expr b
e (Id -> Expr b
forall b. Id -> Expr b
varToCoreExpr Id
a)) Expr b
f [Id]
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 (Id -> Arg b
forall b. Id -> Expr b
Var (DataCon -> Id
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
External instance of the constraint type Foldable []
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] -> [Id] -> Expr b
mkConApp2 DataCon
con [Type]
tys [Id]
arg_ids = Id -> Expr b
forall b. Id -> Expr b
Var (DataCon -> Id
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` (Id -> Expr b) -> [Id] -> [Expr b]
forall a b. (a -> b) -> [a] -> [b]
map Id -> Expr b
forall b. Id -> Expr b
varToCoreExpr [Id]
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 :: Platform -> Integer -> Expr b
mkIntLitInt :: Platform -> Int -> Expr b
mkIntLit :: Platform -> Integer -> Expr b
mkIntLit Platform
platform Integer
n = Literal -> Expr b
forall b. Literal -> Expr b
Lit (Platform -> Integer -> Literal
mkLitInt Platform
platform Integer
n)
mkIntLitInt :: Platform -> ConTag -> Expr b
mkIntLitInt Platform
platform ConTag
n = Literal -> Expr b
forall b. Literal -> Expr b
Lit (Platform -> Integer -> Literal
mkLitInt Platform
platform (ConTag -> Integer
forall a. Integral a => a -> Integer
External instance of the constraint type Integral ConTag
toInteger ConTag
n))
mkWordLit :: Platform -> Integer -> Expr b
mkWordLitWord :: Platform -> Word -> Expr b
mkWordLit :: Platform -> Integer -> Expr b
mkWordLit Platform
platform Integer
w = Literal -> Expr b
forall b. Literal -> Expr b
Lit (Platform -> Integer -> Literal
mkLitWord Platform
platform Integer
w)
mkWordLitWord :: Platform -> Word -> Expr b
mkWordLitWord Platform
platform Word
w = Literal -> Expr b
forall b. Literal -> Expr b
Lit (Platform -> Integer -> Literal
mkLitWord Platform
platform (Word -> Integer
forall a. Integral a => a -> Integer
External instance of the constraint type Integral Word
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
External instance of the constraint type Integral Word64
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
External instance of the constraint type Integral Int64
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
External instance of the constraint type Real Float
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
External instance of the constraint type Real Double
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
External instance of the constraint type Foldable []
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
External instance of the constraint type Foldable []
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 :: Id -> Type -> Bind Id
mkTyBind Id
tv Type
ty = Id -> CoreExpr -> Bind Id
forall b. b -> Expr b -> Bind b
NonRec Id
tv (Type -> CoreExpr
forall b. Type -> Expr b
Type Type
ty)
mkCoBind :: CoVar -> Coercion -> CoreBind
mkCoBind :: Id -> Coercion -> Bind Id
mkCoBind Id
cv Coercion
co = Id -> CoreExpr -> Bind Id
forall b. b -> Expr b -> Bind b
NonRec Id
cv (Coercion -> CoreExpr
forall b. Coercion -> Expr b
Coercion Coercion
co)
varToCoreExpr :: CoreBndr -> Expr b
varToCoreExpr :: Id -> Expr b
varToCoreExpr Id
v | Id -> Bool
isTyVar Id
v = Type -> Expr b
forall b. Type -> Expr b
Type (Id -> Type
mkTyVarTy Id
v)
| Id -> Bool
isCoVar Id
v = Coercion -> Expr b
forall b. Coercion -> Expr b
Coercion (Id -> Coercion
mkCoVarCo Id
v)
| Bool
otherwise = ASSERT( isId v ) Var v
varsToCoreExprs :: [CoreBndr] -> [Expr b]
varsToCoreExprs :: [Id] -> [Expr b]
varsToCoreExprs [Id]
vs = (Id -> Expr b) -> [Id] -> [Expr b]
forall a b. (a -> b) -> [a] -> [b]
map Id -> Expr b
forall b. Id -> Expr b
varToCoreExpr [Id]
vs
applyTypeToArg :: Type -> CoreExpr -> Type
applyTypeToArg :: Type -> CoreExpr -> Type
applyTypeToArg Type
fun_ty CoreExpr
arg = HasDebugCallStack => Type -> Type -> Type
Type -> Type -> Type
External instance of the constraint type HasDebugCallStack
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
External instance of the constraint type Foldable []
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 -> ([Id], CoreExpr)
collectTyBinders CoreExpr
expr
= [Id] -> CoreExpr -> ([Id], CoreExpr)
go [] CoreExpr
expr
where
go :: [Id] -> CoreExpr -> ([Id], CoreExpr)
go [Id]
tvs (Lam Id
b CoreExpr
e) | Id -> Bool
isTyVar Id
b = [Id] -> CoreExpr -> ([Id], CoreExpr)
go (Id
bId -> [Id] -> [Id]
forall a. a -> [a] -> [a]
:[Id]
tvs) CoreExpr
e
go [Id]
tvs CoreExpr
e = ([Id] -> [Id]
forall a. [a] -> [a]
reverse [Id]
tvs, CoreExpr
e)
collectValBinders :: CoreExpr -> ([Id], CoreExpr)
collectValBinders CoreExpr
expr
= [Id] -> CoreExpr -> ([Id], CoreExpr)
go [] CoreExpr
expr
where
go :: [Id] -> CoreExpr -> ([Id], CoreExpr)
go [Id]
ids (Lam Id
b CoreExpr
e) | Id -> Bool
isId Id
b = [Id] -> CoreExpr -> ([Id], CoreExpr)
go (Id
bId -> [Id] -> [Id]
forall a. a -> [a] -> [a]
:[Id]
ids) CoreExpr
e
go [Id]
ids CoreExpr
body = ([Id] -> [Id]
forall a. [a] -> [a]
reverse [Id]
ids, CoreExpr
body)
collectTyAndValBinders :: CoreExpr -> ([Id], [Id], CoreExpr)
collectTyAndValBinders CoreExpr
expr
= ([Id]
tvs, [Id]
ids, CoreExpr
body)
where
([Id]
tvs, CoreExpr
body1) = CoreExpr -> ([Id], CoreExpr)
collectTyBinders CoreExpr
expr
([Id]
ids, CoreExpr
body) = CoreExpr -> ([Id], CoreExpr)
collectValBinders CoreExpr
body1
collectNBinders :: ConTag -> Expr b -> ([b], Expr b)
collectNBinders ConTag
orig_n Expr b
orig_expr
= ConTag -> [b] -> Expr b -> ([b], Expr b)
forall {t} {a}.
(Eq t, Num t) =>
t -> [a] -> Expr a -> ([a], Expr a)
External instance of the constraint type Num ConTag
External instance of the constraint type Eq ConTag
go ConTag
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
Evidence bound by a type signature of the constraint type Num t
-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
$ ConTag -> SDoc
int ConTag
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 Id
_ 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
External instance of the constraint type Num Word
- 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 Id -> Bool) -> Expr b -> (Expr b, [Expr b], [Tickish Id])
collectArgsTicks Tickish Id -> Bool
skipTick Expr b
expr
= Expr b
-> [Expr b] -> [Tickish Id] -> (Expr b, [Expr b], [Tickish Id])
forall {b}.
Expr b
-> [Expr b] -> [Tickish Id] -> (Expr b, [Expr b], [Tickish Id])
go Expr b
expr [] []
where
go :: Expr b
-> [Expr b] -> [Tickish Id] -> (Expr b, [Expr b], [Tickish Id])
go (App Expr b
f Expr b
a) [Expr b]
as [Tickish Id]
ts = Expr b
-> [Expr b] -> [Tickish Id] -> (Expr b, [Expr b], [Tickish Id])
go Expr b
f (Expr b
aExpr b -> [Expr b] -> [Expr b]
forall a. a -> [a] -> [a]
:[Expr b]
as) [Tickish Id]
ts
go (Tick Tickish Id
t Expr b
e) [Expr b]
as [Tickish Id]
ts
| Tickish Id -> Bool
skipTick Tickish Id
t = Expr b
-> [Expr b] -> [Tickish Id] -> (Expr b, [Expr b], [Tickish Id])
go Expr b
e [Expr b]
as (Tickish Id
tTickish Id -> [Tickish Id] -> [Tickish Id]
forall a. a -> [a] -> [a]
:[Tickish Id]
ts)
go Expr b
e [Expr b]
as [Tickish Id]
ts = (Expr b
e, [Expr b]
as, [Tickish Id] -> [Tickish Id]
forall a. [a] -> [a]
reverse [Tickish Id]
ts)
isRuntimeVar :: Var -> Bool
isRuntimeVar :: Id -> Bool
isRuntimeVar = Id -> 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 :: [Id] -> ConTag
valBndrCount = (Id -> Bool) -> [Id] -> ConTag
forall a. (a -> Bool) -> [a] -> ConTag
count Id -> Bool
isId
valArgCount :: [Arg b] -> Int
valArgCount :: [Arg b] -> ConTag
valArgCount = (Arg b -> Bool) -> [Arg b] -> ConTag
forall a. (a -> Bool) -> [a] -> ConTag
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 Id -> Bool)
-> AnnExpr b a -> (AnnExpr b a, [AnnExpr b a], [Tickish Id])
collectAnnArgsTicks Tickish Id -> Bool
tickishOk AnnExpr b a
expr
= AnnExpr b a
-> [AnnExpr b a]
-> [Tickish Id]
-> (AnnExpr b a, [AnnExpr b a], [Tickish Id])
forall {bndr} {annot}.
AnnExpr bndr annot
-> [AnnExpr bndr annot]
-> [Tickish Id]
-> (AnnExpr bndr annot, [AnnExpr bndr annot], [Tickish Id])
go AnnExpr b a
expr [] []
where
go :: AnnExpr bndr annot
-> [AnnExpr bndr annot]
-> [Tickish Id]
-> (AnnExpr bndr annot, [AnnExpr bndr annot], [Tickish Id])
go (annot
_, AnnApp AnnExpr bndr annot
f AnnExpr bndr annot
a) [AnnExpr bndr annot]
as [Tickish Id]
ts = AnnExpr bndr annot
-> [AnnExpr bndr annot]
-> [Tickish Id]
-> (AnnExpr bndr annot, [AnnExpr bndr annot], [Tickish Id])
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 Id]
ts
go (annot
_, AnnTick Tickish Id
t AnnExpr bndr annot
e) [AnnExpr bndr annot]
as [Tickish Id]
ts | Tickish Id -> Bool
tickishOk Tickish Id
t
= AnnExpr bndr annot
-> [AnnExpr bndr annot]
-> [Tickish Id]
-> (AnnExpr bndr annot, [AnnExpr bndr annot], [Tickish Id])
go AnnExpr bndr annot
e [AnnExpr bndr annot]
as (Tickish Id
tTickish Id -> [Tickish Id] -> [Tickish Id]
forall a. a -> [a] -> [a]
:[Tickish Id]
ts)
go AnnExpr bndr annot
e [AnnExpr bndr annot]
as [Tickish Id]
ts = (AnnExpr bndr annot
e, [AnnExpr bndr annot]
as, [Tickish Id] -> [Tickish Id]
forall a. [a] -> [a]
reverse [Tickish Id]
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 Id
v) = Id -> Expr bndr
forall b. Id -> Expr b
Var Id
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 Id
tick AnnExpr bndr annot
body) = Tickish Id -> Expr bndr -> Expr bndr
forall b. Tickish Id -> Expr b -> Expr b
Tick Tickish Id
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 :: ConTag -> AnnExpr bndr annot -> ([bndr], AnnExpr bndr annot)
collectNAnnBndrs ConTag
orig_n AnnExpr bndr annot
e
= ConTag
-> [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)
External instance of the constraint type Num ConTag
External instance of the constraint type Eq ConTag
collect ConTag
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
Evidence bound by a type signature of the constraint type Num t
-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
$ ConTag -> SDoc
int ConTag
orig_n