{-# LANGUAGE MultiWayIf, PatternSynonyms #-}
{-# OPTIONS_GHC -Wno-incomplete-record-updates #-}
{-# LANGUAGE DeriveFunctor #-}
module GHC.Types.Var (
Var, CoVar, Id, NcId, DictId, DFunId, EvVar, EqVar, EvId, IpId, JoinId,
TyVar, TcTyVar, TypeVar, KindVar, TKVar, TyCoVar,
InVar, InCoVar, InId, InTyVar,
OutVar, OutCoVar, OutId, OutTyVar,
varName, varUnique, varType,
varMultMaybe, idMult,
setVarName, setVarUnique, setVarType,
updateVarType, updateVarTypeM,
mkGlobalVar, mkLocalVar, mkExportedLocalVar, mkCoVar,
idInfo, idDetails,
lazySetIdInfo, setIdDetails, globaliseId,
setIdExported, setIdNotExported, setIdMult,
updateIdTypeButNotMult,
updateIdTypeAndMult, updateIdTypeAndMultM,
isId, isTyVar, isTcTyVar,
isLocalVar, isLocalId, isLocalId_maybe, isCoVar, isNonCoVarId, isTyCoVar,
isGlobalId, isExportedId,
mustHaveLocalBinding,
ForAllTyFlag(Invisible,Required,Specified,Inferred),
Specificity(..),
isVisibleForAllTyFlag, isInvisibleForAllTyFlag, isInferredForAllTyFlag,
isSpecifiedForAllTyFlag,
coreTyLamForAllTyFlag,
FunTyFlag(..), isVisibleFunArg, isInvisibleFunArg, isFUNArg,
mkFunTyFlag, visArg, invisArg,
visArgTypeLike, visArgConstraintLike,
invisArgTypeLike, invisArgConstraintLike,
funTyFlagArgTypeOrConstraint, funTyFlagResultTypeOrConstraint,
TypeOrConstraint(..),
PiTyBinder(..), PiTyVarBinder,
isInvisiblePiTyBinder, isInvisibleAnonPiTyBinder,
isVisiblePiTyBinder,
isTyBinder, isNamedPiTyBinder, isAnonPiTyBinder,
namedPiTyBinder_maybe, anonPiTyBinderType_maybe, piTyBinderType,
VarBndr(..), ForAllTyBinder, TyVarBinder,
InvisTyBinder, InvisTVBinder, ReqTyBinder, ReqTVBinder,
binderVar, binderVars, binderFlag, binderFlags, binderType,
mkForAllTyBinder, mkForAllTyBinders,
mkTyVarBinder, mkTyVarBinders,
isVisibleForAllTyBinder, isInvisibleForAllTyBinder, isTyVarBinder,
tyVarSpecToBinder, tyVarSpecToBinders, tyVarReqToBinder, tyVarReqToBinders,
mapVarBndr, mapVarBndrs,
ExportFlag(..),
mkTyVar, mkTcTyVar,
tyVarName, tyVarKind, tcTyVarDetails, setTcTyVarDetails,
setTyVarName, setTyVarUnique, setTyVarKind, updateTyVarKind,
updateTyVarKindM,
nonDetCmpVar
) where
import GHC.Prelude
import {-# SOURCE #-} GHC.Core.TyCo.Rep( Type, Kind, Mult, Scaled, scaledThing )
import {-# SOURCE #-} GHC.Core.TyCo.Ppr( pprKind )
import {-# SOURCE #-} GHC.Tc.Utils.TcType( TcTyVarDetails, pprTcTyVarDetails, vanillaSkolemTvUnk )
import {-# SOURCE #-} GHC.Types.Id.Info( IdDetails, IdInfo, coVarDetails, isCoVarDetails,
vanillaIdInfo, pprIdDetails )
import {-# SOURCE #-} GHC.Builtin.Types ( manyDataConTy )
import GHC.Types.Name hiding (varName)
import GHC.Types.Unique ( Uniquable, Unique, getKey, getUnique
, nonDetCmpUnique )
import GHC.Types.Basic( TypeOrConstraint(..) )
import GHC.Utils.Misc
import GHC.Utils.Binary
import GHC.Utils.Outputable
import GHC.Utils.Panic
import GHC.Hs.Specificity ()
import Language.Haskell.Syntax.Specificity
import Data.Data
type Id = Var
type CoVar = Id
type NcId = Id
type TyVar = Var
type TKVar = Var
type TcTyVar = Var
type TypeVar = Var
type KindVar = Var
type EvId = Id
type EvVar = EvId
type DFunId = Id
type DictId = EvId
type IpId = EvId
type EqVar = EvId
type JoinId = Id
type TyCoVar = Id
type InVar = Var
type InTyVar = TyVar
type InCoVar = CoVar
type InId = Id
type OutVar = Var
type OutTyVar = TyVar
type OutCoVar = CoVar
type OutId = Id
data Var
= TyVar {
Id -> Name
varName :: !Name,
Id -> Unique
realUnique :: {-# UNPACK #-} !Unique,
Id -> Mult
varType :: Kind
}
| TcTyVar {
varName :: !Name,
realUnique :: {-# UNPACK #-} !Unique,
varType :: Kind,
Id -> TcTyVarDetails
tc_tv_details :: TcTyVarDetails
}
| Id {
varName :: !Name,
realUnique :: {-# UNPACK #-} !Unique,
varType :: Type,
Id -> Mult
varMult :: Mult,
Id -> IdScope
idScope :: IdScope,
Id -> IdDetails
id_details :: IdDetails,
Id -> IdInfo
id_info :: IdInfo }
data IdScope
= GlobalId
| LocalId ExportFlag
data ExportFlag
= NotExported
| Exported
instance Outputable Var where
ppr :: Id -> SDoc
ppr Id
var = SDoc -> (PprStyle -> SDoc) -> SDoc
forall doc. IsOutput doc => doc -> (PprStyle -> SDoc) -> doc
docWithStyle SDoc
ppr_code PprStyle -> SDoc
ppr_normal
where
ppr_code :: SDoc
ppr_code = Name -> SDoc
forall a. Outputable a => a -> SDoc
ppr (Id -> Name
varName Id
var)
ppr_normal :: PprStyle -> SDoc
ppr_normal PprStyle
sty = (SDocContext -> Bool) -> (Bool -> SDoc) -> SDoc
forall a. (SDocContext -> a) -> (a -> SDoc) -> SDoc
sdocOption SDocContext -> Bool
sdocSuppressVarKinds ((Bool -> SDoc) -> SDoc) -> (Bool -> SDoc) -> SDoc
forall a b. (a -> b) -> a -> b
$ \Bool
supp_var_kinds ->
(Bool -> SDoc) -> SDoc
forall doc. IsOutput doc => (Bool -> doc) -> doc
getPprDebug ((Bool -> SDoc) -> SDoc) -> (Bool -> SDoc) -> SDoc
forall a b. (a -> b) -> a -> b
$ \Bool
debug ->
let
ppr_var :: SDoc
ppr_var = case Id
var of
(TyVar {})
| Bool
debug
-> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
brackets (String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"tv")
(TcTyVar {tc_tv_details :: Id -> TcTyVarDetails
tc_tv_details = TcTyVarDetails
d})
| PprStyle -> Bool
dumpStyle PprStyle
sty Bool -> Bool -> Bool
|| Bool
debug
-> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
brackets (TcTyVarDetails -> SDoc
pprTcTyVarDetails TcTyVarDetails
d)
(Id { idScope :: Id -> IdScope
idScope = IdScope
s, id_details :: Id -> IdDetails
id_details = IdDetails
d })
| Bool
debug
-> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
brackets (IdScope -> SDoc
ppr_id_scope IdScope
s SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> IdDetails -> SDoc
pprIdDetails IdDetails
d)
Id
_ -> SDoc
forall doc. IsOutput doc => doc
empty
in if
| Bool
debug Bool -> Bool -> Bool
&& (Bool -> Bool
not Bool
supp_var_kinds)
-> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
parens (Name -> SDoc
forall a. Outputable a => a -> SDoc
ppr (Id -> Name
varName Id
var) SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> Maybe Mult -> SDoc
forall a. Outputable a => a -> SDoc
ppr (Id -> Maybe Mult
varMultMaybe Id
var)
SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
ppr_var SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+>
SDoc
dcolon SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> Mult -> SDoc
pprKind (Id -> Mult
tyVarKind Id
var))
| Bool
otherwise
-> Name -> SDoc
forall a. Outputable a => a -> SDoc
ppr (Id -> Name
varName Id
var) SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> SDoc
ppr_var
ppr_id_scope :: IdScope -> SDoc
ppr_id_scope :: IdScope -> SDoc
ppr_id_scope IdScope
GlobalId = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"gid"
ppr_id_scope (LocalId ExportFlag
Exported) = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"lidx"
ppr_id_scope (LocalId ExportFlag
NotExported) = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"lid"
instance NamedThing Var where
getName :: Id -> Name
getName = Id -> Name
varName
instance Uniquable Var where
getUnique :: Id -> Unique
getUnique = Id -> Unique
varUnique
instance Eq Var where
Id
a == :: Id -> Id -> Bool
== Id
b = Id -> Unique
realUnique Id
a Unique -> Unique -> Bool
forall a. Eq a => a -> a -> Bool
== Id -> Unique
realUnique Id
b
instance Ord Var where
Id
a <= :: Id -> Id -> Bool
<= Id
b = Unique -> Word64
getKey (Id -> Unique
realUnique Id
a) Word64 -> Word64 -> Bool
forall a. Ord a => a -> a -> Bool
<= Unique -> Word64
getKey (Id -> Unique
realUnique Id
b)
Id
a < :: Id -> Id -> Bool
< Id
b = Unique -> Word64
getKey (Id -> Unique
realUnique Id
a) Word64 -> Word64 -> Bool
forall a. Ord a => a -> a -> Bool
< Unique -> Word64
getKey (Id -> Unique
realUnique Id
b)
Id
a >= :: Id -> Id -> Bool
>= Id
b = Unique -> Word64
getKey (Id -> Unique
realUnique Id
a) Word64 -> Word64 -> Bool
forall a. Ord a => a -> a -> Bool
>= Unique -> Word64
getKey (Id -> Unique
realUnique Id
b)
Id
a > :: Id -> Id -> Bool
> Id
b = Unique -> Word64
getKey (Id -> Unique
realUnique Id
a) Word64 -> Word64 -> Bool
forall a. Ord a => a -> a -> Bool
> Unique -> Word64
getKey (Id -> Unique
realUnique Id
b)
Id
a compare :: Id -> Id -> Ordering
`compare` Id
b = Id
a Id -> Id -> Ordering
`nonDetCmpVar` Id
b
nonDetCmpVar :: Var -> Var -> Ordering
nonDetCmpVar :: Id -> Id -> Ordering
nonDetCmpVar Id
a Id
b = Id -> Unique
varUnique Id
a Unique -> Unique -> Ordering
`nonDetCmpUnique` Id -> Unique
varUnique Id
b
instance Data Var where
toConstr :: Id -> Constr
toConstr Id
_ = String -> Constr
abstractConstr String
"Var"
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Id
gunfold forall b r. Data b => c (b -> r) -> c r
_ forall r. r -> c r
_ = String -> Constr -> c Id
forall a. HasCallStack => String -> a
error String
"gunfold"
dataTypeOf :: Id -> DataType
dataTypeOf Id
_ = String -> DataType
mkNoRepType String
"Var"
instance HasOccName Var where
occName :: Id -> OccName
occName = Name -> OccName
nameOccName (Name -> OccName) -> (Id -> Name) -> Id -> OccName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Id -> Name
varName
varUnique :: Var -> Unique
varUnique :: Id -> Unique
varUnique Id
var = Id -> Unique
realUnique Id
var
varMultMaybe :: Id -> Maybe Mult
varMultMaybe :: Id -> Maybe Mult
varMultMaybe (Id { varMult :: Id -> Mult
varMult = Mult
mult }) = Mult -> Maybe Mult
forall a. a -> Maybe a
Just Mult
mult
varMultMaybe Id
_ = Maybe Mult
forall a. Maybe a
Nothing
idMult :: HasDebugCallStack => Id -> Mult
idMult :: HasDebugCallStack => Id -> Mult
idMult (Id { varMult :: Id -> Mult
varMult = Mult
mult }) = Mult
mult
idMult Id
non_id = String -> SDoc -> Mult
forall a. HasCallStack => String -> SDoc -> a
pprPanic String
"idMult" (Id -> SDoc
forall a. Outputable a => a -> SDoc
ppr Id
non_id)
setVarUnique :: Var -> Unique -> Var
setVarUnique :: Id -> Unique -> Id
setVarUnique Id
var Unique
uniq
= Id
var { realUnique = uniq,
varName = setNameUnique (varName var) uniq }
setVarName :: Var -> Name -> Var
setVarName :: Id -> Name -> Id
setVarName Id
var Name
new_name
= Id
var { realUnique = getUnique new_name,
varName = new_name }
setVarType :: Var -> Type -> Var
setVarType :: Id -> Mult -> Id
setVarType Id
id Mult
ty = Id
id { varType = ty }
updateVarType :: (Type -> Type) -> Var -> Var
updateVarType :: (Mult -> Mult) -> Id -> Id
updateVarType Mult -> Mult
upd Id
var
= case Id
var of
Id { id_details :: Id -> IdDetails
id_details = IdDetails
details } -> Bool -> Id -> Id
forall a. HasCallStack => Bool -> a -> a
assert (IdDetails -> Bool
isCoVarDetails IdDetails
details) (Id -> Id) -> Id -> Id
forall a b. (a -> b) -> a -> b
$
Id
result
Id
_ -> Id
result
where
result :: Id
result = Id
var { varType = upd (varType var) }
updateVarTypeM :: Monad m => (Type -> m Type) -> Var -> m Var
updateVarTypeM :: forall (m :: * -> *). Monad m => (Mult -> m Mult) -> Id -> m Id
updateVarTypeM Mult -> m Mult
upd Id
var
= case Id
var of
Id { id_details :: Id -> IdDetails
id_details = IdDetails
details } -> Bool -> m Id -> m Id
forall a. HasCallStack => Bool -> a -> a
assert (IdDetails -> Bool
isCoVarDetails IdDetails
details) (m Id -> m Id) -> m Id -> m Id
forall a b. (a -> b) -> a -> b
$
m Id
result
Id
_ -> m Id
result
where
result :: m Id
result = do { ty' <- Mult -> m Mult
upd (Id -> Mult
varType Id
var)
; return (var { varType = ty' }) }
data FunTyFlag
= FTF_T_T
| FTF_T_C
| FTF_C_T
| FTF_C_C
deriving (FunTyFlag -> FunTyFlag -> Bool
(FunTyFlag -> FunTyFlag -> Bool)
-> (FunTyFlag -> FunTyFlag -> Bool) -> Eq FunTyFlag
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FunTyFlag -> FunTyFlag -> Bool
== :: FunTyFlag -> FunTyFlag -> Bool
$c/= :: FunTyFlag -> FunTyFlag -> Bool
/= :: FunTyFlag -> FunTyFlag -> Bool
Eq, Eq FunTyFlag
Eq FunTyFlag =>
(FunTyFlag -> FunTyFlag -> Ordering)
-> (FunTyFlag -> FunTyFlag -> Bool)
-> (FunTyFlag -> FunTyFlag -> Bool)
-> (FunTyFlag -> FunTyFlag -> Bool)
-> (FunTyFlag -> FunTyFlag -> Bool)
-> (FunTyFlag -> FunTyFlag -> FunTyFlag)
-> (FunTyFlag -> FunTyFlag -> FunTyFlag)
-> Ord FunTyFlag
FunTyFlag -> FunTyFlag -> Bool
FunTyFlag -> FunTyFlag -> Ordering
FunTyFlag -> FunTyFlag -> FunTyFlag
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
$ccompare :: FunTyFlag -> FunTyFlag -> Ordering
compare :: FunTyFlag -> FunTyFlag -> Ordering
$c< :: FunTyFlag -> FunTyFlag -> Bool
< :: FunTyFlag -> FunTyFlag -> Bool
$c<= :: FunTyFlag -> FunTyFlag -> Bool
<= :: FunTyFlag -> FunTyFlag -> Bool
$c> :: FunTyFlag -> FunTyFlag -> Bool
> :: FunTyFlag -> FunTyFlag -> Bool
$c>= :: FunTyFlag -> FunTyFlag -> Bool
>= :: FunTyFlag -> FunTyFlag -> Bool
$cmax :: FunTyFlag -> FunTyFlag -> FunTyFlag
max :: FunTyFlag -> FunTyFlag -> FunTyFlag
$cmin :: FunTyFlag -> FunTyFlag -> FunTyFlag
min :: FunTyFlag -> FunTyFlag -> FunTyFlag
Ord, Typeable FunTyFlag
Typeable FunTyFlag =>
(forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> FunTyFlag -> c FunTyFlag)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c FunTyFlag)
-> (FunTyFlag -> Constr)
-> (FunTyFlag -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c FunTyFlag))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c FunTyFlag))
-> ((forall b. Data b => b -> b) -> FunTyFlag -> FunTyFlag)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> FunTyFlag -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> FunTyFlag -> r)
-> (forall u. (forall d. Data d => d -> u) -> FunTyFlag -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> FunTyFlag -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> FunTyFlag -> m FunTyFlag)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> FunTyFlag -> m FunTyFlag)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> FunTyFlag -> m FunTyFlag)
-> Data FunTyFlag
FunTyFlag -> Constr
FunTyFlag -> DataType
(forall b. Data b => b -> b) -> FunTyFlag -> FunTyFlag
forall a.
Typeable a =>
(forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> FunTyFlag -> u
forall u. (forall d. Data d => d -> u) -> FunTyFlag -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> FunTyFlag -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> FunTyFlag -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> FunTyFlag -> m FunTyFlag
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> FunTyFlag -> m FunTyFlag
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c FunTyFlag
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> FunTyFlag -> c FunTyFlag
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c FunTyFlag)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c FunTyFlag)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> FunTyFlag -> c FunTyFlag
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> FunTyFlag -> c FunTyFlag
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c FunTyFlag
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c FunTyFlag
$ctoConstr :: FunTyFlag -> Constr
toConstr :: FunTyFlag -> Constr
$cdataTypeOf :: FunTyFlag -> DataType
dataTypeOf :: FunTyFlag -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c FunTyFlag)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c FunTyFlag)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c FunTyFlag)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c FunTyFlag)
$cgmapT :: (forall b. Data b => b -> b) -> FunTyFlag -> FunTyFlag
gmapT :: (forall b. Data b => b -> b) -> FunTyFlag -> FunTyFlag
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> FunTyFlag -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> FunTyFlag -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> FunTyFlag -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> FunTyFlag -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> FunTyFlag -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> FunTyFlag -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> FunTyFlag -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> FunTyFlag -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> FunTyFlag -> m FunTyFlag
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> FunTyFlag -> m FunTyFlag
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> FunTyFlag -> m FunTyFlag
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> FunTyFlag -> m FunTyFlag
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> FunTyFlag -> m FunTyFlag
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> FunTyFlag -> m FunTyFlag
Data)
instance Outputable FunTyFlag where
ppr :: FunTyFlag -> SDoc
ppr FunTyFlag
FTF_T_T = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"[->]"
ppr FunTyFlag
FTF_T_C = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"[-=>]"
ppr FunTyFlag
FTF_C_T = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"[=>]"
ppr FunTyFlag
FTF_C_C = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"[==>]"
instance Binary FunTyFlag where
put_ :: WriteBinHandle -> FunTyFlag -> IO ()
put_ WriteBinHandle
bh FunTyFlag
FTF_T_T = WriteBinHandle -> Word8 -> IO ()
putByte WriteBinHandle
bh Word8
0
put_ WriteBinHandle
bh FunTyFlag
FTF_T_C = WriteBinHandle -> Word8 -> IO ()
putByte WriteBinHandle
bh Word8
1
put_ WriteBinHandle
bh FunTyFlag
FTF_C_T = WriteBinHandle -> Word8 -> IO ()
putByte WriteBinHandle
bh Word8
2
put_ WriteBinHandle
bh FunTyFlag
FTF_C_C = WriteBinHandle -> Word8 -> IO ()
putByte WriteBinHandle
bh Word8
3
get :: ReadBinHandle -> IO FunTyFlag
get ReadBinHandle
bh = do
h <- ReadBinHandle -> IO Word8
getByte ReadBinHandle
bh
case h of
Word8
0 -> FunTyFlag -> IO FunTyFlag
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return FunTyFlag
FTF_T_T
Word8
1 -> FunTyFlag -> IO FunTyFlag
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return FunTyFlag
FTF_T_C
Word8
2 -> FunTyFlag -> IO FunTyFlag
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return FunTyFlag
FTF_C_T
Word8
_ -> FunTyFlag -> IO FunTyFlag
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return FunTyFlag
FTF_C_C
mkFunTyFlag :: TypeOrConstraint -> TypeOrConstraint -> FunTyFlag
mkFunTyFlag :: TypeOrConstraint -> TypeOrConstraint -> FunTyFlag
mkFunTyFlag TypeOrConstraint
TypeLike TypeOrConstraint
torc = TypeOrConstraint -> FunTyFlag
visArg TypeOrConstraint
torc
mkFunTyFlag TypeOrConstraint
ConstraintLike TypeOrConstraint
torc = TypeOrConstraint -> FunTyFlag
invisArg TypeOrConstraint
torc
visArg :: TypeOrConstraint -> FunTyFlag
visArg :: TypeOrConstraint -> FunTyFlag
visArg TypeOrConstraint
TypeLike = FunTyFlag
FTF_T_T
visArg TypeOrConstraint
ConstraintLike = FunTyFlag
FTF_T_C
visArgTypeLike :: FunTyFlag
visArgTypeLike :: FunTyFlag
visArgTypeLike = FunTyFlag
FTF_T_T
visArgConstraintLike :: FunTyFlag
visArgConstraintLike :: FunTyFlag
visArgConstraintLike = FunTyFlag
FTF_T_C
invisArg :: TypeOrConstraint -> FunTyFlag
invisArg :: TypeOrConstraint -> FunTyFlag
invisArg TypeOrConstraint
TypeLike = FunTyFlag
FTF_C_T
invisArg TypeOrConstraint
ConstraintLike = FunTyFlag
FTF_C_C
invisArgTypeLike :: FunTyFlag
invisArgTypeLike :: FunTyFlag
invisArgTypeLike = FunTyFlag
FTF_C_T
invisArgConstraintLike :: FunTyFlag
invisArgConstraintLike :: FunTyFlag
invisArgConstraintLike = FunTyFlag
FTF_C_C
isInvisibleFunArg :: FunTyFlag -> Bool
isInvisibleFunArg :: FunTyFlag -> Bool
isInvisibleFunArg FunTyFlag
af = Bool -> Bool
not (FunTyFlag -> Bool
isVisibleFunArg FunTyFlag
af)
isVisibleFunArg :: FunTyFlag -> Bool
isVisibleFunArg :: FunTyFlag -> Bool
isVisibleFunArg FunTyFlag
FTF_T_T = Bool
True
isVisibleFunArg FunTyFlag
FTF_T_C = Bool
True
isVisibleFunArg FunTyFlag
_ = Bool
False
isFUNArg :: FunTyFlag -> Bool
isFUNArg :: FunTyFlag -> Bool
isFUNArg FunTyFlag
FTF_T_T = Bool
True
isFUNArg FunTyFlag
_ = Bool
False
funTyFlagArgTypeOrConstraint :: FunTyFlag -> TypeOrConstraint
funTyFlagArgTypeOrConstraint :: FunTyFlag -> TypeOrConstraint
funTyFlagArgTypeOrConstraint FunTyFlag
FTF_T_T = TypeOrConstraint
TypeLike
funTyFlagArgTypeOrConstraint FunTyFlag
FTF_T_C = TypeOrConstraint
TypeLike
funTyFlagArgTypeOrConstraint FunTyFlag
_ = TypeOrConstraint
ConstraintLike
funTyFlagResultTypeOrConstraint :: FunTyFlag -> TypeOrConstraint
funTyFlagResultTypeOrConstraint :: FunTyFlag -> TypeOrConstraint
funTyFlagResultTypeOrConstraint FunTyFlag
FTF_T_T = TypeOrConstraint
TypeLike
funTyFlagResultTypeOrConstraint FunTyFlag
FTF_C_T = TypeOrConstraint
TypeLike
funTyFlagResultTypeOrConstraint FunTyFlag
_ = TypeOrConstraint
ConstraintLike
data VarBndr var argf = Bndr var argf
deriving( Typeable (VarBndr var argf)
Typeable (VarBndr var argf) =>
(forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> VarBndr var argf
-> c (VarBndr var argf))
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (VarBndr var argf))
-> (VarBndr var argf -> Constr)
-> (VarBndr var argf -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (VarBndr var argf)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (VarBndr var argf)))
-> ((forall b. Data b => b -> b)
-> VarBndr var argf -> VarBndr var argf)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> VarBndr var argf -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> VarBndr var argf -> r)
-> (forall u.
(forall d. Data d => d -> u) -> VarBndr var argf -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> VarBndr var argf -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> VarBndr var argf -> m (VarBndr var argf))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> VarBndr var argf -> m (VarBndr var argf))
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> VarBndr var argf -> m (VarBndr var argf))
-> Data (VarBndr var argf)
VarBndr var argf -> Constr
VarBndr var argf -> DataType
(forall b. Data b => b -> b)
-> VarBndr var argf -> VarBndr var argf
forall a.
Typeable a =>
(forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u.
Int -> (forall d. Data d => d -> u) -> VarBndr var argf -> u
forall u. (forall d. Data d => d -> u) -> VarBndr var argf -> [u]
forall var argf.
(Data var, Data argf) =>
Typeable (VarBndr var argf)
forall var argf.
(Data var, Data argf) =>
VarBndr var argf -> Constr
forall var argf.
(Data var, Data argf) =>
VarBndr var argf -> DataType
forall var argf.
(Data var, Data argf) =>
(forall b. Data b => b -> b)
-> VarBndr var argf -> VarBndr var argf
forall var argf u.
(Data var, Data argf) =>
Int -> (forall d. Data d => d -> u) -> VarBndr var argf -> u
forall var argf u.
(Data var, Data argf) =>
(forall d. Data d => d -> u) -> VarBndr var argf -> [u]
forall var argf r r'.
(Data var, Data argf) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> VarBndr var argf -> r
forall var argf r r'.
(Data var, Data argf) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> VarBndr var argf -> r
forall var argf (m :: * -> *).
(Data var, Data argf, Monad m) =>
(forall d. Data d => d -> m d)
-> VarBndr var argf -> m (VarBndr var argf)
forall var argf (m :: * -> *).
(Data var, Data argf, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> VarBndr var argf -> m (VarBndr var argf)
forall var argf (c :: * -> *).
(Data var, Data argf) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (VarBndr var argf)
forall var argf (c :: * -> *).
(Data var, Data argf) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> VarBndr var argf -> c (VarBndr var argf)
forall var argf (t :: * -> *) (c :: * -> *).
(Data var, Data argf, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (VarBndr var argf))
forall var argf (t :: * -> * -> *) (c :: * -> *).
(Data var, Data argf, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (VarBndr var argf))
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> VarBndr var argf -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> VarBndr var argf -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> VarBndr var argf -> m (VarBndr var argf)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> VarBndr var argf -> m (VarBndr var argf)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (VarBndr var argf)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> VarBndr var argf -> c (VarBndr var argf)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (VarBndr var argf))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (VarBndr var argf))
$cgfoldl :: forall var argf (c :: * -> *).
(Data var, Data argf) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> VarBndr var argf -> c (VarBndr var argf)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> VarBndr var argf -> c (VarBndr var argf)
$cgunfold :: forall var argf (c :: * -> *).
(Data var, Data argf) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (VarBndr var argf)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (VarBndr var argf)
$ctoConstr :: forall var argf.
(Data var, Data argf) =>
VarBndr var argf -> Constr
toConstr :: VarBndr var argf -> Constr
$cdataTypeOf :: forall var argf.
(Data var, Data argf) =>
VarBndr var argf -> DataType
dataTypeOf :: VarBndr var argf -> DataType
$cdataCast1 :: forall var argf (t :: * -> *) (c :: * -> *).
(Data var, Data argf, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (VarBndr var argf))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (VarBndr var argf))
$cdataCast2 :: forall var argf (t :: * -> * -> *) (c :: * -> *).
(Data var, Data argf, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (VarBndr var argf))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (VarBndr var argf))
$cgmapT :: forall var argf.
(Data var, Data argf) =>
(forall b. Data b => b -> b)
-> VarBndr var argf -> VarBndr var argf
gmapT :: (forall b. Data b => b -> b)
-> VarBndr var argf -> VarBndr var argf
$cgmapQl :: forall var argf r r'.
(Data var, Data argf) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> VarBndr var argf -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> VarBndr var argf -> r
$cgmapQr :: forall var argf r r'.
(Data var, Data argf) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> VarBndr var argf -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> VarBndr var argf -> r
$cgmapQ :: forall var argf u.
(Data var, Data argf) =>
(forall d. Data d => d -> u) -> VarBndr var argf -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> VarBndr var argf -> [u]
$cgmapQi :: forall var argf u.
(Data var, Data argf) =>
Int -> (forall d. Data d => d -> u) -> VarBndr var argf -> u
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> VarBndr var argf -> u
$cgmapM :: forall var argf (m :: * -> *).
(Data var, Data argf, Monad m) =>
(forall d. Data d => d -> m d)
-> VarBndr var argf -> m (VarBndr var argf)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> VarBndr var argf -> m (VarBndr var argf)
$cgmapMp :: forall var argf (m :: * -> *).
(Data var, Data argf, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> VarBndr var argf -> m (VarBndr var argf)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> VarBndr var argf -> m (VarBndr var argf)
$cgmapMo :: forall var argf (m :: * -> *).
(Data var, Data argf, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> VarBndr var argf -> m (VarBndr var argf)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> VarBndr var argf -> m (VarBndr var argf)
Data, VarBndr var argf -> VarBndr var argf -> Bool
(VarBndr var argf -> VarBndr var argf -> Bool)
-> (VarBndr var argf -> VarBndr var argf -> Bool)
-> Eq (VarBndr var argf)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall var argf.
(Eq var, Eq argf) =>
VarBndr var argf -> VarBndr var argf -> Bool
$c== :: forall var argf.
(Eq var, Eq argf) =>
VarBndr var argf -> VarBndr var argf -> Bool
== :: VarBndr var argf -> VarBndr var argf -> Bool
$c/= :: forall var argf.
(Eq var, Eq argf) =>
VarBndr var argf -> VarBndr var argf -> Bool
/= :: VarBndr var argf -> VarBndr var argf -> Bool
Eq, Eq (VarBndr var argf)
Eq (VarBndr var argf) =>
(VarBndr var argf -> VarBndr var argf -> Ordering)
-> (VarBndr var argf -> VarBndr var argf -> Bool)
-> (VarBndr var argf -> VarBndr var argf -> Bool)
-> (VarBndr var argf -> VarBndr var argf -> Bool)
-> (VarBndr var argf -> VarBndr var argf -> Bool)
-> (VarBndr var argf -> VarBndr var argf -> VarBndr var argf)
-> (VarBndr var argf -> VarBndr var argf -> VarBndr var argf)
-> Ord (VarBndr var argf)
VarBndr var argf -> VarBndr var argf -> Bool
VarBndr var argf -> VarBndr var argf -> Ordering
VarBndr var argf -> VarBndr var argf -> VarBndr var argf
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 var argf. (Ord var, Ord argf) => Eq (VarBndr var argf)
forall var argf.
(Ord var, Ord argf) =>
VarBndr var argf -> VarBndr var argf -> Bool
forall var argf.
(Ord var, Ord argf) =>
VarBndr var argf -> VarBndr var argf -> Ordering
forall var argf.
(Ord var, Ord argf) =>
VarBndr var argf -> VarBndr var argf -> VarBndr var argf
$ccompare :: forall var argf.
(Ord var, Ord argf) =>
VarBndr var argf -> VarBndr var argf -> Ordering
compare :: VarBndr var argf -> VarBndr var argf -> Ordering
$c< :: forall var argf.
(Ord var, Ord argf) =>
VarBndr var argf -> VarBndr var argf -> Bool
< :: VarBndr var argf -> VarBndr var argf -> Bool
$c<= :: forall var argf.
(Ord var, Ord argf) =>
VarBndr var argf -> VarBndr var argf -> Bool
<= :: VarBndr var argf -> VarBndr var argf -> Bool
$c> :: forall var argf.
(Ord var, Ord argf) =>
VarBndr var argf -> VarBndr var argf -> Bool
> :: VarBndr var argf -> VarBndr var argf -> Bool
$c>= :: forall var argf.
(Ord var, Ord argf) =>
VarBndr var argf -> VarBndr var argf -> Bool
>= :: VarBndr var argf -> VarBndr var argf -> Bool
$cmax :: forall var argf.
(Ord var, Ord argf) =>
VarBndr var argf -> VarBndr var argf -> VarBndr var argf
max :: VarBndr var argf -> VarBndr var argf -> VarBndr var argf
$cmin :: forall var argf.
(Ord var, Ord argf) =>
VarBndr var argf -> VarBndr var argf -> VarBndr var argf
min :: VarBndr var argf -> VarBndr var argf -> VarBndr var argf
Ord)
type ForAllTyBinder = VarBndr TyCoVar ForAllTyFlag
type InvisTyBinder = VarBndr TyCoVar Specificity
type ReqTyBinder = VarBndr TyCoVar ()
type TyVarBinder = VarBndr TyVar ForAllTyFlag
type InvisTVBinder = VarBndr TyVar Specificity
type ReqTVBinder = VarBndr TyVar ()
tyVarSpecToBinders :: [VarBndr a Specificity] -> [VarBndr a ForAllTyFlag]
tyVarSpecToBinders :: forall a. [VarBndr a Specificity] -> [VarBndr a ForAllTyFlag]
tyVarSpecToBinders = (VarBndr a Specificity -> VarBndr a ForAllTyFlag)
-> [VarBndr a Specificity] -> [VarBndr a ForAllTyFlag]
forall a b. (a -> b) -> [a] -> [b]
map VarBndr a Specificity -> VarBndr a ForAllTyFlag
forall a. VarBndr a Specificity -> VarBndr a ForAllTyFlag
tyVarSpecToBinder
tyVarSpecToBinder :: VarBndr a Specificity -> VarBndr a ForAllTyFlag
tyVarSpecToBinder :: forall a. VarBndr a Specificity -> VarBndr a ForAllTyFlag
tyVarSpecToBinder (Bndr a
tv Specificity
vis) = a -> ForAllTyFlag -> VarBndr a ForAllTyFlag
forall var argf. var -> argf -> VarBndr var argf
Bndr a
tv (Specificity -> ForAllTyFlag
Invisible Specificity
vis)
tyVarReqToBinders :: [VarBndr a ()] -> [VarBndr a ForAllTyFlag]
tyVarReqToBinders :: forall a. [VarBndr a ()] -> [VarBndr a ForAllTyFlag]
tyVarReqToBinders = (VarBndr a () -> VarBndr a ForAllTyFlag)
-> [VarBndr a ()] -> [VarBndr a ForAllTyFlag]
forall a b. (a -> b) -> [a] -> [b]
map VarBndr a () -> VarBndr a ForAllTyFlag
forall a. VarBndr a () -> VarBndr a ForAllTyFlag
tyVarReqToBinder
tyVarReqToBinder :: VarBndr a () -> VarBndr a ForAllTyFlag
tyVarReqToBinder :: forall a. VarBndr a () -> VarBndr a ForAllTyFlag
tyVarReqToBinder (Bndr a
tv ()
_) = a -> ForAllTyFlag -> VarBndr a ForAllTyFlag
forall var argf. var -> argf -> VarBndr var argf
Bndr a
tv ForAllTyFlag
Required
isVisibleForAllTyBinder :: ForAllTyBinder -> Bool
isVisibleForAllTyBinder :: ForAllTyBinder -> Bool
isVisibleForAllTyBinder (Bndr Id
_ ForAllTyFlag
vis) = ForAllTyFlag -> Bool
isVisibleForAllTyFlag ForAllTyFlag
vis
isInvisibleForAllTyBinder :: ForAllTyBinder -> Bool
isInvisibleForAllTyBinder :: ForAllTyBinder -> Bool
isInvisibleForAllTyBinder (Bndr Id
_ ForAllTyFlag
vis) = ForAllTyFlag -> Bool
isInvisibleForAllTyFlag ForAllTyFlag
vis
binderVar :: VarBndr tv argf -> tv
binderVar :: forall tv argf. VarBndr tv argf -> tv
binderVar (Bndr tv
v argf
_) = tv
v
binderVars :: [VarBndr tv argf] -> [tv]
binderVars :: forall tv argf. [VarBndr tv argf] -> [tv]
binderVars [VarBndr tv argf]
tvbs = (VarBndr tv argf -> tv) -> [VarBndr tv argf] -> [tv]
forall a b. (a -> b) -> [a] -> [b]
map VarBndr tv argf -> tv
forall tv argf. VarBndr tv argf -> tv
binderVar [VarBndr tv argf]
tvbs
binderFlag :: VarBndr tv argf -> argf
binderFlag :: forall tv argf. VarBndr tv argf -> argf
binderFlag (Bndr tv
_ argf
argf) = argf
argf
binderFlags :: [VarBndr tv argf] -> [argf]
binderFlags :: forall tv argf. [VarBndr tv argf] -> [argf]
binderFlags [VarBndr tv argf]
tvbs = (VarBndr tv argf -> argf) -> [VarBndr tv argf] -> [argf]
forall a b. (a -> b) -> [a] -> [b]
map VarBndr tv argf -> argf
forall tv argf. VarBndr tv argf -> argf
binderFlag [VarBndr tv argf]
tvbs
binderType :: VarBndr TyCoVar argf -> Type
binderType :: forall argf. VarBndr Id argf -> Mult
binderType (Bndr Id
tv argf
_) = Id -> Mult
varType Id
tv
isTyVarBinder :: VarBndr TyCoVar vis -> Bool
isTyVarBinder :: forall vis. VarBndr Id vis -> Bool
isTyVarBinder (Bndr Id
tcv vis
_) = Id -> Bool
isTyVar Id
tcv
mkForAllTyBinder :: vis -> TyCoVar -> VarBndr TyCoVar vis
mkForAllTyBinder :: forall vis. vis -> Id -> VarBndr Id vis
mkForAllTyBinder vis
vis Id
var = Id -> vis -> VarBndr Id vis
forall var argf. var -> argf -> VarBndr var argf
Bndr Id
var vis
vis
mkTyVarBinder :: vis -> TyVar -> VarBndr TyVar vis
mkTyVarBinder :: forall vis. vis -> Id -> VarBndr Id vis
mkTyVarBinder vis
vis Id
var
= Bool -> VarBndr Id vis -> VarBndr Id vis
forall a. HasCallStack => Bool -> a -> a
assert (Id -> Bool
isTyVar Id
var) (VarBndr Id vis -> VarBndr Id vis)
-> VarBndr Id vis -> VarBndr Id vis
forall a b. (a -> b) -> a -> b
$
Id -> vis -> VarBndr Id vis
forall var argf. var -> argf -> VarBndr var argf
Bndr Id
var vis
vis
mkForAllTyBinders :: vis -> [TyCoVar] -> [VarBndr TyCoVar vis]
mkForAllTyBinders :: forall vis. vis -> [Id] -> [VarBndr Id vis]
mkForAllTyBinders vis
vis = (Id -> VarBndr Id vis) -> [Id] -> [VarBndr Id vis]
forall a b. (a -> b) -> [a] -> [b]
map (vis -> Id -> VarBndr Id vis
forall vis. vis -> Id -> VarBndr Id vis
mkForAllTyBinder vis
vis)
mkTyVarBinders :: vis -> [TyVar] -> [VarBndr TyVar vis]
mkTyVarBinders :: forall vis. vis -> [Id] -> [VarBndr Id vis]
mkTyVarBinders vis
vis = (Id -> VarBndr Id vis) -> [Id] -> [VarBndr Id vis]
forall a b. (a -> b) -> [a] -> [b]
map (vis -> Id -> VarBndr Id vis
forall vis. vis -> Id -> VarBndr Id vis
mkTyVarBinder vis
vis)
mapVarBndr :: (var -> var') -> (VarBndr var flag) -> (VarBndr var' flag)
mapVarBndr :: forall var var' flag.
(var -> var') -> VarBndr var flag -> VarBndr var' flag
mapVarBndr var -> var'
f (Bndr var
v flag
fl) = var' -> flag -> VarBndr var' flag
forall var argf. var -> argf -> VarBndr var argf
Bndr (var -> var'
f var
v) flag
fl
mapVarBndrs :: (var -> var') -> [VarBndr var flag] -> [VarBndr var' flag]
mapVarBndrs :: forall var var' flag.
(var -> var') -> [VarBndr var flag] -> [VarBndr var' flag]
mapVarBndrs var -> var'
f = (VarBndr var flag -> VarBndr var' flag)
-> [VarBndr var flag] -> [VarBndr var' flag]
forall a b. (a -> b) -> [a] -> [b]
map ((var -> var') -> VarBndr var flag -> VarBndr var' flag
forall var var' flag.
(var -> var') -> VarBndr var flag -> VarBndr var' flag
mapVarBndr var -> var'
f)
instance Outputable tv => Outputable (VarBndr tv ForAllTyFlag) where
ppr :: VarBndr tv ForAllTyFlag -> SDoc
ppr (Bndr tv
v ForAllTyFlag
Required) = tv -> SDoc
forall a. Outputable a => a -> SDoc
ppr tv
v
ppr (Bndr tv
v ForAllTyFlag
Specified) = Char -> SDoc
forall doc. IsLine doc => Char -> doc
char Char
'@' SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> tv -> SDoc
forall a. Outputable a => a -> SDoc
ppr tv
v
ppr (Bndr tv
v ForAllTyFlag
Inferred) = SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
braces (tv -> SDoc
forall a. Outputable a => a -> SDoc
ppr tv
v)
instance Outputable tv => Outputable (VarBndr tv Specificity) where
ppr :: VarBndr tv Specificity -> SDoc
ppr = VarBndr tv ForAllTyFlag -> SDoc
forall a. Outputable a => a -> SDoc
ppr (VarBndr tv ForAllTyFlag -> SDoc)
-> (VarBndr tv Specificity -> VarBndr tv ForAllTyFlag)
-> VarBndr tv Specificity
-> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VarBndr tv Specificity -> VarBndr tv ForAllTyFlag
forall a. VarBndr a Specificity -> VarBndr a ForAllTyFlag
tyVarSpecToBinder
instance (Binary tv, Binary vis) => Binary (VarBndr tv vis) where
put_ :: WriteBinHandle -> VarBndr tv vis -> IO ()
put_ WriteBinHandle
bh (Bndr tv
tv vis
vis) = do { WriteBinHandle -> tv -> IO ()
forall a. Binary a => WriteBinHandle -> a -> IO ()
put_ WriteBinHandle
bh tv
tv; WriteBinHandle -> vis -> IO ()
forall a. Binary a => WriteBinHandle -> a -> IO ()
put_ WriteBinHandle
bh vis
vis }
get :: ReadBinHandle -> IO (VarBndr tv vis)
get ReadBinHandle
bh = do { tv <- ReadBinHandle -> IO tv
forall a. Binary a => ReadBinHandle -> IO a
get ReadBinHandle
bh; vis <- get bh; return (Bndr tv vis) }
instance NamedThing tv => NamedThing (VarBndr tv flag) where
getName :: VarBndr tv flag -> Name
getName (Bndr tv
tv flag
_) = tv -> Name
forall a. NamedThing a => a -> Name
getName tv
tv
data PiTyBinder
= Named ForAllTyBinder
| Anon (Scaled Type) FunTyFlag
deriving Typeable PiTyBinder
Typeable PiTyBinder =>
(forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PiTyBinder -> c PiTyBinder)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c PiTyBinder)
-> (PiTyBinder -> Constr)
-> (PiTyBinder -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c PiTyBinder))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c PiTyBinder))
-> ((forall b. Data b => b -> b) -> PiTyBinder -> PiTyBinder)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PiTyBinder -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> PiTyBinder -> r)
-> (forall u. (forall d. Data d => d -> u) -> PiTyBinder -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> PiTyBinder -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> PiTyBinder -> m PiTyBinder)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PiTyBinder -> m PiTyBinder)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PiTyBinder -> m PiTyBinder)
-> Data PiTyBinder
PiTyBinder -> Constr
PiTyBinder -> DataType
(forall b. Data b => b -> b) -> PiTyBinder -> PiTyBinder
forall a.
Typeable a =>
(forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> PiTyBinder -> u
forall u. (forall d. Data d => d -> u) -> PiTyBinder -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PiTyBinder -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> PiTyBinder -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> PiTyBinder -> m PiTyBinder
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PiTyBinder -> m PiTyBinder
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c PiTyBinder
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PiTyBinder -> c PiTyBinder
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c PiTyBinder)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c PiTyBinder)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PiTyBinder -> c PiTyBinder
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PiTyBinder -> c PiTyBinder
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c PiTyBinder
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c PiTyBinder
$ctoConstr :: PiTyBinder -> Constr
toConstr :: PiTyBinder -> Constr
$cdataTypeOf :: PiTyBinder -> DataType
dataTypeOf :: PiTyBinder -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c PiTyBinder)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c PiTyBinder)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c PiTyBinder)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c PiTyBinder)
$cgmapT :: (forall b. Data b => b -> b) -> PiTyBinder -> PiTyBinder
gmapT :: (forall b. Data b => b -> b) -> PiTyBinder -> PiTyBinder
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PiTyBinder -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PiTyBinder -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> PiTyBinder -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> PiTyBinder -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> PiTyBinder -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> PiTyBinder -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> PiTyBinder -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> PiTyBinder -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> PiTyBinder -> m PiTyBinder
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> PiTyBinder -> m PiTyBinder
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PiTyBinder -> m PiTyBinder
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PiTyBinder -> m PiTyBinder
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PiTyBinder -> m PiTyBinder
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PiTyBinder -> m PiTyBinder
Data
instance Outputable PiTyBinder where
ppr :: PiTyBinder -> SDoc
ppr (Anon Scaled Mult
ty FunTyFlag
af) = FunTyFlag -> SDoc
forall a. Outputable a => a -> SDoc
ppr FunTyFlag
af SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> Scaled Mult -> SDoc
forall a. Outputable a => a -> SDoc
ppr Scaled Mult
ty
ppr (Named (Bndr Id
v ForAllTyFlag
Required)) = Id -> SDoc
forall a. Outputable a => a -> SDoc
ppr Id
v
ppr (Named (Bndr Id
v ForAllTyFlag
Specified)) = Char -> SDoc
forall doc. IsLine doc => Char -> doc
char Char
'@' SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> Id -> SDoc
forall a. Outputable a => a -> SDoc
ppr Id
v
ppr (Named (Bndr Id
v ForAllTyFlag
Inferred)) = SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
braces (Id -> SDoc
forall a. Outputable a => a -> SDoc
ppr Id
v)
type PiTyVarBinder = PiTyBinder
isInvisiblePiTyBinder :: PiTyBinder -> Bool
isInvisiblePiTyBinder :: PiTyBinder -> Bool
isInvisiblePiTyBinder (Named (Bndr Id
_ ForAllTyFlag
vis)) = ForAllTyFlag -> Bool
isInvisibleForAllTyFlag ForAllTyFlag
vis
isInvisiblePiTyBinder (Anon Scaled Mult
_ FunTyFlag
af) = FunTyFlag -> Bool
isInvisibleFunArg FunTyFlag
af
isInvisibleAnonPiTyBinder :: PiTyBinder -> Bool
isInvisibleAnonPiTyBinder :: PiTyBinder -> Bool
isInvisibleAnonPiTyBinder (Named {}) = Bool
False
isInvisibleAnonPiTyBinder (Anon Scaled Mult
_ FunTyFlag
af) = FunTyFlag -> Bool
isInvisibleFunArg FunTyFlag
af
isVisiblePiTyBinder :: PiTyBinder -> Bool
isVisiblePiTyBinder :: PiTyBinder -> Bool
isVisiblePiTyBinder = Bool -> Bool
not (Bool -> Bool) -> (PiTyBinder -> Bool) -> PiTyBinder -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PiTyBinder -> Bool
isInvisiblePiTyBinder
isNamedPiTyBinder :: PiTyBinder -> Bool
isNamedPiTyBinder :: PiTyBinder -> Bool
isNamedPiTyBinder (Named {}) = Bool
True
isNamedPiTyBinder (Anon {}) = Bool
False
namedPiTyBinder_maybe :: PiTyBinder -> Maybe TyCoVar
namedPiTyBinder_maybe :: PiTyBinder -> Maybe Id
namedPiTyBinder_maybe (Named ForAllTyBinder
tv) = Id -> Maybe Id
forall a. a -> Maybe a
Just (Id -> Maybe Id) -> Id -> Maybe Id
forall a b. (a -> b) -> a -> b
$ ForAllTyBinder -> Id
forall tv argf. VarBndr tv argf -> tv
binderVar ForAllTyBinder
tv
namedPiTyBinder_maybe PiTyBinder
_ = Maybe Id
forall a. Maybe a
Nothing
isAnonPiTyBinder :: PiTyBinder -> Bool
isAnonPiTyBinder :: PiTyBinder -> Bool
isAnonPiTyBinder (Named {}) = Bool
False
isAnonPiTyBinder (Anon {}) = Bool
True
anonPiTyBinderType_maybe :: PiTyBinder -> Maybe Type
anonPiTyBinderType_maybe :: PiTyBinder -> Maybe Mult
anonPiTyBinderType_maybe (Named {}) = Maybe Mult
forall a. Maybe a
Nothing
anonPiTyBinderType_maybe (Anon Scaled Mult
ty FunTyFlag
_) = Mult -> Maybe Mult
forall a. a -> Maybe a
Just (Scaled Mult -> Mult
forall a. Scaled a -> a
scaledThing Scaled Mult
ty)
isTyBinder :: PiTyBinder -> Bool
isTyBinder :: PiTyBinder -> Bool
isTyBinder (Named ForAllTyBinder
bnd) = ForAllTyBinder -> Bool
forall vis. VarBndr Id vis -> Bool
isTyVarBinder ForAllTyBinder
bnd
isTyBinder PiTyBinder
_ = Bool
True
piTyBinderType :: PiTyBinder -> Type
piTyBinderType :: PiTyBinder -> Mult
piTyBinderType (Named (Bndr Id
tv ForAllTyFlag
_)) = Id -> Mult
varType Id
tv
piTyBinderType (Anon Scaled Mult
ty FunTyFlag
_) = Scaled Mult -> Mult
forall a. Scaled a -> a
scaledThing Scaled Mult
ty
tyVarName :: TyVar -> Name
tyVarName :: Id -> Name
tyVarName = Id -> Name
varName
tyVarKind :: TyVar -> Kind
tyVarKind :: Id -> Mult
tyVarKind = Id -> Mult
varType
setTyVarUnique :: TyVar -> Unique -> TyVar
setTyVarUnique :: Id -> Unique -> Id
setTyVarUnique = Id -> Unique -> Id
setVarUnique
setTyVarName :: TyVar -> Name -> TyVar
setTyVarName :: Id -> Name -> Id
setTyVarName = Id -> Name -> Id
setVarName
setTyVarKind :: TyVar -> Kind -> TyVar
setTyVarKind :: Id -> Mult -> Id
setTyVarKind Id
tv Mult
k = Id
tv {varType = k}
updateTyVarKind :: (Kind -> Kind) -> TyVar -> TyVar
updateTyVarKind :: (Mult -> Mult) -> Id -> Id
updateTyVarKind Mult -> Mult
update Id
tv = Id
tv {varType = update (tyVarKind tv)}
updateTyVarKindM :: (Monad m) => (Kind -> m Kind) -> TyVar -> m TyVar
updateTyVarKindM :: forall (m :: * -> *). Monad m => (Mult -> m Mult) -> Id -> m Id
updateTyVarKindM Mult -> m Mult
update Id
tv
= do { k' <- Mult -> m Mult
update (Id -> Mult
tyVarKind Id
tv)
; return $ tv {varType = k'} }
mkTyVar :: Name -> Kind -> TyVar
mkTyVar :: Name -> Mult -> Id
mkTyVar Name
name Mult
kind = TyVar { varName :: Name
varName = Name
name
, realUnique :: Unique
realUnique = Name -> Unique
nameUnique Name
name
, varType :: Mult
varType = Mult
kind
}
mkTcTyVar :: Name -> Kind -> TcTyVarDetails -> TyVar
mkTcTyVar :: Name -> Mult -> TcTyVarDetails -> Id
mkTcTyVar Name
name Mult
kind TcTyVarDetails
details
=
TcTyVar { varName :: Name
varName = Name
name,
realUnique :: Unique
realUnique = Name -> Unique
nameUnique Name
name,
varType :: Mult
varType = Mult
kind,
tc_tv_details :: TcTyVarDetails
tc_tv_details = TcTyVarDetails
details
}
tcTyVarDetails :: TyVar -> TcTyVarDetails
tcTyVarDetails :: Id -> TcTyVarDetails
tcTyVarDetails (TcTyVar { tc_tv_details :: Id -> TcTyVarDetails
tc_tv_details = TcTyVarDetails
details }) = TcTyVarDetails
details
tcTyVarDetails (TyVar {}) = TcTyVarDetails
HasDebugCallStack => TcTyVarDetails
vanillaSkolemTvUnk
tcTyVarDetails Id
var = String -> SDoc -> TcTyVarDetails
forall a. HasCallStack => String -> SDoc -> a
pprPanic String
"tcTyVarDetails" (Id -> SDoc
forall a. Outputable a => a -> SDoc
ppr Id
var SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
dcolon SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> Mult -> SDoc
pprKind (Id -> Mult
tyVarKind Id
var))
setTcTyVarDetails :: TyVar -> TcTyVarDetails -> TyVar
setTcTyVarDetails :: Id -> TcTyVarDetails -> Id
setTcTyVarDetails Id
tv TcTyVarDetails
details = Id
tv { tc_tv_details = details }
idInfo :: HasDebugCallStack => Id -> IdInfo
idInfo :: HasDebugCallStack => Id -> IdInfo
idInfo (Id { id_info :: Id -> IdInfo
id_info = IdInfo
info }) = IdInfo
info
idInfo Id
other = String -> SDoc -> IdInfo
forall a. HasCallStack => String -> SDoc -> a
pprPanic String
"idInfo" (Id -> SDoc
forall a. Outputable a => a -> SDoc
ppr Id
other)
idDetails :: Id -> IdDetails
idDetails :: Id -> IdDetails
idDetails (Id { id_details :: Id -> IdDetails
id_details = IdDetails
details }) = IdDetails
details
idDetails Id
other = String -> SDoc -> IdDetails
forall a. HasCallStack => String -> SDoc -> a
pprPanic String
"idDetails" (Id -> SDoc
forall a. Outputable a => a -> SDoc
ppr Id
other)
mkGlobalVar :: IdDetails -> Name -> Type -> IdInfo -> Id
mkGlobalVar :: IdDetails -> Name -> Mult -> IdInfo -> Id
mkGlobalVar IdDetails
details Name
name Mult
ty IdInfo
info
= Name -> Mult -> Mult -> IdScope -> IdDetails -> IdInfo -> Id
mk_id Name
name Mult
manyDataConTy Mult
ty IdScope
GlobalId IdDetails
details IdInfo
info
mkLocalVar :: IdDetails -> Name -> Mult -> Type -> IdInfo -> Id
mkLocalVar :: IdDetails -> Name -> Mult -> Mult -> IdInfo -> Id
mkLocalVar IdDetails
details Name
name Mult
w Mult
ty IdInfo
info
= Name -> Mult -> Mult -> IdScope -> IdDetails -> IdInfo -> Id
mk_id Name
name Mult
w Mult
ty (ExportFlag -> IdScope
LocalId ExportFlag
NotExported) IdDetails
details IdInfo
info
mkCoVar :: Name -> Type -> CoVar
mkCoVar :: Name -> Mult -> Id
mkCoVar Name
name Mult
ty = Name -> Mult -> Mult -> IdScope -> IdDetails -> IdInfo -> Id
mk_id Name
name Mult
manyDataConTy Mult
ty (ExportFlag -> IdScope
LocalId ExportFlag
NotExported) IdDetails
coVarDetails IdInfo
vanillaIdInfo
mkExportedLocalVar :: IdDetails -> Name -> Type -> IdInfo -> Id
mkExportedLocalVar :: IdDetails -> Name -> Mult -> IdInfo -> Id
mkExportedLocalVar IdDetails
details Name
name Mult
ty IdInfo
info
= Name -> Mult -> Mult -> IdScope -> IdDetails -> IdInfo -> Id
mk_id Name
name Mult
manyDataConTy Mult
ty (ExportFlag -> IdScope
LocalId ExportFlag
Exported) IdDetails
details IdInfo
info
mk_id :: Name -> Mult -> Type -> IdScope -> IdDetails -> IdInfo -> Id
mk_id :: Name -> Mult -> Mult -> IdScope -> IdDetails -> IdInfo -> Id
mk_id Name
name !Mult
w Mult
ty IdScope
scope IdDetails
details IdInfo
info
= Id { varName :: Name
varName = Name
name,
realUnique :: Unique
realUnique = Name -> Unique
nameUnique Name
name,
varMult :: Mult
varMult = Mult
w,
varType :: Mult
varType = Mult
ty,
idScope :: IdScope
idScope = IdScope
scope,
id_details :: IdDetails
id_details = IdDetails
details,
id_info :: IdInfo
id_info = IdInfo
info }
lazySetIdInfo :: Id -> IdInfo -> Var
lazySetIdInfo :: Id -> IdInfo -> Id
lazySetIdInfo Id
id IdInfo
info = Id
id { id_info = info }
setIdDetails :: Id -> IdDetails -> Id
setIdDetails :: Id -> IdDetails -> Id
setIdDetails Id
id IdDetails
details = Id
id { id_details = details }
globaliseId :: Id -> Id
globaliseId :: Id -> Id
globaliseId Id
id = Id
id { idScope = GlobalId }
setIdExported :: Id -> Id
setIdExported :: Id -> Id
setIdExported id :: Id
id@(Id { idScope :: Id -> IdScope
idScope = LocalId {} }) = Id
id { idScope = LocalId Exported }
setIdExported id :: Id
id@(Id { idScope :: Id -> IdScope
idScope = IdScope
GlobalId }) = Id
id
setIdExported Id
tv = String -> SDoc -> Id
forall a. HasCallStack => String -> SDoc -> a
pprPanic String
"setIdExported" (Id -> SDoc
forall a. Outputable a => a -> SDoc
ppr Id
tv)
setIdNotExported :: Id -> Id
setIdNotExported :: Id -> Id
setIdNotExported Id
id = Bool -> Id -> Id
forall a. HasCallStack => Bool -> a -> a
assert (Id -> Bool
isLocalId Id
id) (Id -> Id) -> Id -> Id
forall a b. (a -> b) -> a -> b
$
Id
id { idScope = LocalId NotExported }
updateIdTypeButNotMult :: (Type -> Type) -> Id -> Id
updateIdTypeButNotMult :: (Mult -> Mult) -> Id -> Id
updateIdTypeButNotMult Mult -> Mult
f Id
id = Id
id { varType = f (varType id) }
updateIdTypeAndMult :: (Type -> Type) -> Id -> Id
updateIdTypeAndMult :: (Mult -> Mult) -> Id -> Id
updateIdTypeAndMult Mult -> Mult
f id :: Id
id@(Id { varType :: Id -> Mult
varType = Mult
ty
, varMult :: Id -> Mult
varMult = Mult
mult })
= Id
id { varType = ty'
, varMult = mult' }
where
!ty' :: Mult
ty' = Mult -> Mult
f Mult
ty
!mult' :: Mult
mult' = Mult -> Mult
f Mult
mult
updateIdTypeAndMult Mult -> Mult
_ Id
other = String -> SDoc -> Id
forall a. HasCallStack => String -> SDoc -> a
pprPanic String
"updateIdTypeAndMult" (Id -> SDoc
forall a. Outputable a => a -> SDoc
ppr Id
other)
updateIdTypeAndMultM :: Monad m => (Type -> m Type) -> Id -> m Id
updateIdTypeAndMultM :: forall (m :: * -> *). Monad m => (Mult -> m Mult) -> Id -> m Id
updateIdTypeAndMultM Mult -> m Mult
f id :: Id
id@(Id { varType :: Id -> Mult
varType = Mult
ty
, varMult :: Id -> Mult
varMult = Mult
mult })
= do { !ty' <- Mult -> m Mult
f Mult
ty
; !mult' <- f mult
; return (id { varType = ty', varMult = mult' }) }
updateIdTypeAndMultM Mult -> m Mult
_ Id
other = String -> SDoc -> m Id
forall a. HasCallStack => String -> SDoc -> a
pprPanic String
"updateIdTypeAndMultM" (Id -> SDoc
forall a. Outputable a => a -> SDoc
ppr Id
other)
setIdMult :: Id -> Mult -> Id
setIdMult :: Id -> Mult -> Id
setIdMult Id
id !Mult
r | Id -> Bool
isId Id
id = Id
id { varMult = r }
| Bool
otherwise = String -> SDoc -> Id
forall a. HasCallStack => String -> SDoc -> a
pprPanic String
"setIdMult" (Id -> SDoc
forall a. Outputable a => a -> SDoc
ppr Id
id SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> Mult -> SDoc
forall a. Outputable a => a -> SDoc
ppr Mult
r)
isTyVar :: Var -> Bool
isTyVar :: Id -> Bool
isTyVar (TyVar {}) = Bool
True
isTyVar (TcTyVar {}) = Bool
True
isTyVar Id
_ = Bool
False
isTcTyVar :: Var -> Bool
isTcTyVar :: Id -> Bool
isTcTyVar (TcTyVar {}) = Bool
True
isTcTyVar Id
_ = Bool
False
isTyCoVar :: Var -> Bool
isTyCoVar :: Id -> Bool
isTyCoVar Id
v = Id -> Bool
isTyVar Id
v Bool -> Bool -> Bool
|| Id -> Bool
isCoVar Id
v
isId :: Var -> Bool
isId :: Id -> Bool
isId (Id {}) = Bool
True
isId Id
_ = Bool
False
isCoVar :: Var -> Bool
isCoVar :: Id -> Bool
isCoVar (Id { id_details :: Id -> IdDetails
id_details = IdDetails
details }) = IdDetails -> Bool
isCoVarDetails IdDetails
details
isCoVar Id
_ = Bool
False
isNonCoVarId :: Var -> Bool
isNonCoVarId :: Id -> Bool
isNonCoVarId (Id { id_details :: Id -> IdDetails
id_details = IdDetails
details }) = Bool -> Bool
not (IdDetails -> Bool
isCoVarDetails IdDetails
details)
isNonCoVarId Id
_ = Bool
False
isLocalId :: Var -> Bool
isLocalId :: Id -> Bool
isLocalId (Id { idScope :: Id -> IdScope
idScope = LocalId ExportFlag
_ }) = Bool
True
isLocalId Id
_ = Bool
False
isLocalId_maybe :: Var -> Maybe ExportFlag
isLocalId_maybe :: Id -> Maybe ExportFlag
isLocalId_maybe (Id { idScope :: Id -> IdScope
idScope = LocalId ExportFlag
ef }) = ExportFlag -> Maybe ExportFlag
forall a. a -> Maybe a
Just ExportFlag
ef
isLocalId_maybe Id
_ = Maybe ExportFlag
forall a. Maybe a
Nothing
isLocalVar :: Var -> Bool
isLocalVar :: Id -> Bool
isLocalVar Id
v = Bool -> Bool
not (Id -> Bool
isGlobalId Id
v)
isGlobalId :: Var -> Bool
isGlobalId :: Id -> Bool
isGlobalId (Id { idScope :: Id -> IdScope
idScope = IdScope
GlobalId }) = Bool
True
isGlobalId Id
_ = Bool
False
mustHaveLocalBinding :: Var -> Bool
mustHaveLocalBinding :: Id -> Bool
mustHaveLocalBinding Id
var = Id -> Bool
isLocalVar Id
var
isExportedId :: Var -> Bool
isExportedId :: Id -> Bool
isExportedId (Id { idScope :: Id -> IdScope
idScope = IdScope
GlobalId }) = Bool
True
isExportedId (Id { idScope :: Id -> IdScope
idScope = LocalId ExportFlag
Exported}) = Bool
True
isExportedId Id
_ = Bool
False