Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
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 :: MonadTypeChecker m => [(Namespace, Name)] -> m a -> m 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)
- 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
- unknownType :: MonadTypeChecker m => SrcLoc -> QualName Name -> 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 ()
- newName :: VName -> m VName
- newID :: Name -> m VName
- newTypeName :: Name -> m VName
- bindNameMap :: NameMap -> m a -> m a
- bindVal :: VName -> BoundV -> m a -> m a
- checkQualName :: Namespace -> QualName Name -> SrcLoc -> m (QualName VName)
- lookupType :: SrcLoc -> QualName Name -> m (QualName VName, [TypeParam], StructRetType, Liftedness)
- lookupMod :: SrcLoc -> QualName Name -> m (QualName VName, Mod)
- lookupVar :: SrcLoc -> QualName Name -> m (QualName VName, PatType)
- checkNamedSize :: SrcLoc -> QualName Name -> m (QualName VName)
- typeError :: Located loc => loc -> Notes -> Doc () -> m a
- checkName :: MonadTypeChecker m => Namespace -> Name -> SrcLoc -> m VName
- checkAttr :: MonadTypeChecker m => AttrInfo Name -> m (AttrInfo VName)
- badOnLeft :: Either TypeError a -> TypeM a
- module Language.Futhark.Warnings
- data Env = Env {}
- type TySet = Map (QualName VName) Liftedness
- data FunSig = FunSig {}
- type ImportTable = Map ImportName Env
- type NameMap = Map (Namespace, Name) (QualName VName)
- data BoundV = BoundV [TypeParam] StructType
- 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
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 :: MonadTypeChecker m => [(Namespace, Name)] -> m a -> m a Source #
Map source-level names do fresh unique internal names, and evaluate a type checker context with the mapping active.
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 throwError :: TypeError -> TypeM a # catchError :: TypeM a -> (TypeError -> TypeM a) -> TypeM a # | |
MonadError TypeError TermTypeM Source # | |
Defined in Language.Futhark.TypeChecker.Terms.Monad 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.
unknownType :: MonadTypeChecker m => SrcLoc -> QualName Name -> m a Source #
An unknown type 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.
warn, newName, newID, newTypeName, bindNameMap, bindVal, checkQualName, lookupType, lookupMod, lookupVar, typeError
warn :: Located loc => loc -> Doc () -> m () Source #
newName :: VName -> m VName Source #
newID :: Name -> m VName Source #
newTypeName :: Name -> m VName Source #
bindNameMap :: NameMap -> m a -> m a Source #
bindVal :: VName -> BoundV -> m a -> m a Source #
checkQualName :: Namespace -> QualName Name -> SrcLoc -> m (QualName VName) Source #
lookupType :: SrcLoc -> QualName Name -> m (QualName VName, [TypeParam], StructRetType, Liftedness) Source #
lookupMod :: SrcLoc -> QualName Name -> m (QualName VName, Mod) Source #
lookupVar :: SrcLoc -> QualName Name -> m (QualName VName, PatType) Source #
checkNamedSize :: SrcLoc -> QualName Name -> m (QualName VName) Source #
typeError :: Located loc => loc -> Notes -> Doc () -> m a Source #
Instances
checkName :: MonadTypeChecker m => Namespace -> Name -> SrcLoc -> m VName Source #
Elaborate the given name in the given namespace at the given
location, producing the corresponding unique VName
.
checkAttr :: MonadTypeChecker m => AttrInfo Name -> m (AttrInfo VName) Source #
Type-check an attribute.
module Language.Futhark.Warnings
Modules produces environment with this representation.
Env | |
|
type TySet = Map (QualName VName) Liftedness Source #
A mapping of abstract types to their liftedness.
A parametric functor consists of a set of abstract types, the environment of its parameter, and the resulting module type.
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.
Representation of a module, which is either a plain environment, or a parametric module ("functor" in SML).
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
).
Instances
Show TypeBinding Source # | |
Defined in Language.Futhark.Semantic showsPrec :: Int -> TypeBinding -> ShowS # show :: TypeBinding -> String # showList :: [TypeBinding] -> ShowS # | |
Eq TypeBinding Source # | |
Defined in Language.Futhark.Semantic (==) :: TypeBinding -> TypeBinding -> Bool # (/=) :: TypeBinding -> TypeBinding -> Bool # |
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 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 # | |
Defined in Language.Futhark.Semantic | |
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.