Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Language.Futhark.TypeChecker.Monad
Description
Main monad in which the type checker runs, as well as ancillary data definitions.
Synopsis
- data TypeM a
- runTypeM :: Env -> ImportTable -> ImportName -> VNameSource -> TypeM a -> (Warnings, Either TypeError (a, VNameSource))
- askEnv :: TypeM Env
- askImportName :: TypeM ImportName
- atTopLevel :: TypeM Bool
- enteringModule :: TypeM a -> TypeM a
- bindSpaced :: [(Namespace, Name, SrcLoc)] -> ([VName] -> TypeM a) -> TypeM a
- bindSpaced1 :: Namespace -> Name -> SrcLoc -> (VName -> TypeM a) -> TypeM a
- bindIdents :: [IdentBase NoInfo VName t] -> TypeM a -> TypeM a
- qualifyTypeVars :: Env -> [VName] -> [VName] -> TypeBase Size as -> TypeBase Size as
- lookupMTy :: SrcLoc -> QualName Name -> TypeM (QualName VName, MTy)
- lookupImport :: SrcLoc -> FilePath -> TypeM (ImportName, Env)
- lookupMod :: SrcLoc -> QualName Name -> TypeM (QualName VName, Mod)
- localEnv :: Env -> TypeM a -> TypeM a
- data TypeError = TypeError Loc Notes (Doc ())
- prettyTypeError :: TypeError -> Doc AnsiStyle
- prettyTypeErrorNoLoc :: TypeError -> Doc AnsiStyle
- withIndexLink :: Doc a -> Doc a -> Doc a
- unappliedFunctor :: MonadTypeChecker m => SrcLoc -> m a
- unknownVariable :: MonadTypeChecker m => Namespace -> QualName Name -> SrcLoc -> m a
- underscoreUse :: MonadTypeChecker m => SrcLoc -> QualName Name -> m a
- data Notes
- aNote :: Doc () -> Notes
- class Monad m => MonadTypeChecker m where
- warn :: Located loc => loc -> Doc () -> m ()
- warnings :: Warnings -> m ()
- newName :: VName -> m VName
- newID :: Name -> m VName
- newTypeName :: Name -> m VName
- bindVal :: VName -> BoundV -> m a -> m a
- lookupType :: QualName VName -> m ([TypeParam], StructRetType, Liftedness)
- typeError :: Located loc => loc -> Notes -> Doc () -> m a
- data TypeState
- usedName :: VName -> TypeM ()
- checkName :: Namespace -> Name -> SrcLoc -> TypeM VName
- checkAttr :: MonadTypeChecker m => AttrInfo VName -> m (AttrInfo VName)
- checkQualName :: Namespace -> QualName Name -> SrcLoc -> TypeM (QualName VName)
- checkValName :: QualName Name -> SrcLoc -> TypeM (QualName VName)
- badOnLeft :: Either TypeError a -> TypeM a
- isKnownType :: QualName VName -> TypeM Bool
- module Language.Futhark.Warnings
- data Env = Env {}
- type TySet = Map (QualName VName) Liftedness
- data FunModType = FunModType {}
- type ImportTable = Map ImportName Env
- type NameMap = Map (Namespace, Name) (QualName VName)
- data BoundV = BoundV {}
- data Mod
- data TypeBinding = TypeAbbr Liftedness [TypeParam] StructRetType
- data MTy = MTy {}
- anySignedType :: [PrimType]
- anyUnsignedType :: [PrimType]
- anyIntType :: [PrimType]
- anyFloatType :: [PrimType]
- anyNumberType :: [PrimType]
- anyPrimType :: [PrimType]
- data Namespace
- intrinsicsNameMap :: NameMap
- topLevelNameMap :: NameMap
- mkTypeVarName :: Name -> Int -> Name
Documentation
The type checker runs in this monad.
Instances
Applicative TypeM Source # | |
Functor TypeM Source # | |
Monad TypeM Source # | |
MonadTypeChecker TypeM Source # | |
Defined in Language.Futhark.TypeChecker.Monad Methods warn :: Located loc => loc -> Doc () -> TypeM () Source # warnings :: Warnings -> TypeM () Source # newName :: VName -> TypeM VName Source # newID :: Name -> TypeM VName Source # newTypeName :: Name -> TypeM VName Source # bindVal :: VName -> BoundV -> TypeM a -> TypeM a Source # lookupType :: QualName VName -> TypeM ([TypeParam], StructRetType, Liftedness) Source # typeError :: Located loc => loc -> Notes -> Doc () -> TypeM a Source # | |
MonadError TypeError TypeM Source # | |
Defined in Language.Futhark.TypeChecker.Monad Methods throwError :: TypeError -> TypeM a # catchError :: TypeM a -> (TypeError -> TypeM a) -> TypeM a # | |
MonadState TypeState TypeM Source # | |
runTypeM :: Env -> ImportTable -> ImportName -> VNameSource -> TypeM a -> (Warnings, Either TypeError (a, VNameSource)) Source #
Run a TypeM
computation.
askImportName :: TypeM ImportName Source #
The name of the current file/import.
atTopLevel :: TypeM Bool Source #
Are we type-checking at the top level, or are we inside a nested module?
enteringModule :: TypeM a -> TypeM a Source #
We are now going to type-check the body of a module.
bindSpaced :: [(Namespace, Name, SrcLoc)] -> ([VName] -> TypeM a) -> TypeM a Source #
Map source-level names to fresh unique internal names, and evaluate a type checker context with the mapping active.
bindSpaced1 :: Namespace -> Name -> SrcLoc -> (VName -> TypeM a) -> TypeM a Source #
Map single source-level name to fresh unique internal names, and evaluate a type checker context with the mapping active.
bindIdents :: [IdentBase NoInfo VName t] -> TypeM a -> TypeM a Source #
Bind these identifiers in the name map and also check whether they have been used.
qualifyTypeVars :: Env -> [VName] -> [VName] -> TypeBase Size as -> TypeBase Size as Source #
Try to prepend qualifiers to the type names such that they represent how to access the type in some scope.
lookupImport :: SrcLoc -> FilePath -> TypeM (ImportName, Env) Source #
Look up an import.
localEnv :: Env -> TypeM a -> TypeM a Source #
Evaluate a TypeM
computation within an extended (not
replaced) environment.
Information about an error during type checking.
Instances
MonadError TypeError TypeM Source # | |
Defined in Language.Futhark.TypeChecker.Monad Methods throwError :: TypeError -> TypeM a # catchError :: TypeM a -> (TypeError -> TypeM a) -> TypeM a # | |
MonadError TypeError TermTypeM Source # | |
Defined in Language.Futhark.TypeChecker.Terms.Monad Methods throwError :: TypeError -> TermTypeM a # catchError :: TermTypeM a -> (TypeError -> TermTypeM a) -> TermTypeM a # |
prettyTypeErrorNoLoc :: TypeError -> Doc AnsiStyle Source #
Prettyprint type error, without location information. This can be used for cases where the location is printed in some other way.
withIndexLink :: Doc a -> Doc a -> Doc a Source #
Attach a reference to documentation explaining the error in more detail.
unappliedFunctor :: MonadTypeChecker m => SrcLoc -> m a Source #
An unexpected functor appeared!
unknownVariable :: MonadTypeChecker m => Namespace -> QualName Name -> SrcLoc -> m a Source #
An unknown variable was referenced.
underscoreUse :: MonadTypeChecker m => SrcLoc -> QualName Name -> m a Source #
A name prefixed with an underscore was used.
A collection of extra information regarding a type error.
class Monad m => MonadTypeChecker m where Source #
Monads that support type checking. The reason we have this internal interface is because we use distinct monads for checking expressions and declarations.
Minimal complete definition
warn, warnings, newName, newTypeName, bindVal, lookupType, typeError
Methods
warn :: Located loc => loc -> Doc () -> m () Source #
warnings :: Warnings -> m () Source #
newName :: VName -> m VName Source #
newID :: Name -> m VName Source #
newTypeName :: Name -> m VName Source #
bindVal :: VName -> BoundV -> m a -> m a Source #
lookupType :: QualName VName -> m ([TypeParam], StructRetType, Liftedness) Source #
typeError :: Located loc => loc -> Notes -> Doc () -> m a Source #
Instances
usedName :: VName -> TypeM () Source #
Indicate that this name has been used. This is usually done implicitly by other operations, but sometimes we want to make a "fake" use to avoid things like top level functions being considered unused.
checkName :: Namespace -> Name -> SrcLoc -> TypeM VName Source #
Elaborate the given name in the given namespace at the given
location, producing the corresponding unique VName
.
checkAttr :: MonadTypeChecker m => AttrInfo VName -> m (AttrInfo VName) Source #
Type-check an attribute.
checkQualName :: Namespace -> QualName Name -> SrcLoc -> TypeM (QualName VName) Source #
Elaborate the given qualified name in the given namespace at the
given location, producing the corresponding unique QualName
.
checkValName :: QualName Name -> SrcLoc -> TypeM (QualName VName) Source #
Elaborate the given qualified name in the given namespace at the
given location, producing the corresponding unique QualName
.
Fails if the name is a module.
isKnownType :: QualName VName -> TypeM Bool Source #
Does a type with this name already exist? This is used for warnings, so it is OK it's a little unprincipled.
module Language.Futhark.Warnings
Modules produces environment with this representation.
Constructors
Env | |
Fields
|
type TySet = Map (QualName VName) Liftedness Source #
A mapping of abstract types to their liftedness.
data FunModType Source #
A parametric functor consists of a set of abstract types, the environment of its parameter, and the resulting module type.
Constructors
FunModType | |
Fields
|
Instances
Show FunModType Source # | |
Defined in Language.Futhark.Semantic Methods showsPrec :: Int -> FunModType -> ShowS # show :: FunModType -> String # showList :: [FunModType] -> ShowS # |
type ImportTable = Map ImportName Env Source #
A mapping from import import names to Env
s. This is used to
resolve import
declarations.
type NameMap = Map (Namespace, Name) (QualName VName) Source #
A mapping from names (which always exist in some namespace) to a unique (tagged) name.
Type parameters, list of parameter types (optinally named), and return type. The type parameters are in scope in both parameter types and the return type. Non-functional values have only a return type.
Constructors
BoundV | |
Fields |
Representation of a module, which is either a plain environment, or a parametric module ("functor" in SML).
Constructors
ModEnv Env | |
ModFun FunModType |
data TypeBinding Source #
A binding from a name to its definition as a type. We allow a
return type here to support type abbreviations that hide some inner
sizes (these must necessarily be Lifted
or SizeLifted
).
Constructors
TypeAbbr Liftedness [TypeParam] StructRetType |
Instances
Show TypeBinding Source # | |
Defined in Language.Futhark.Semantic Methods showsPrec :: Int -> TypeBinding -> ShowS # show :: TypeBinding -> String # showList :: [TypeBinding] -> ShowS # | |
Eq TypeBinding Source # | |
Defined in Language.Futhark.Semantic |
Representation of a module type.
anySignedType :: [PrimType] Source #
All signed integer types.
anyUnsignedType :: [PrimType] Source #
All unsigned integer types.
anyIntType :: [PrimType] Source #
All integer types.
anyFloatType :: [PrimType] Source #
All floating-point types.
anyNumberType :: [PrimType] Source #
All number types.
anyPrimType :: [PrimType] Source #
All primitive types.
The space inhabited by a name.
Instances
Enum Namespace Source # | |
Defined in Language.Futhark.Semantic Methods succ :: Namespace -> Namespace # pred :: Namespace -> Namespace # fromEnum :: Namespace -> Int # enumFrom :: Namespace -> [Namespace] # enumFromThen :: Namespace -> Namespace -> [Namespace] # enumFromTo :: Namespace -> Namespace -> [Namespace] # enumFromThenTo :: Namespace -> Namespace -> Namespace -> [Namespace] # | |
Show Namespace Source # | |
Eq Namespace Source # | |
Ord Namespace Source # | |
Pretty Namespace Source # | |
Defined in Language.Futhark.Semantic |
intrinsicsNameMap :: NameMap Source #
The NameMap
corresponding to the intrinsics module.
topLevelNameMap :: NameMap Source #
The names that are available in the initial environment.