Safe Haskell | Trustworthy |
---|---|
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
- bindSpaced :: MonadTypeChecker m => [(Namespace, Name)] -> m a -> m a
- qualifyTypeVars :: Env -> [VName] -> [VName] -> TypeBase (DimDecl VName) as -> TypeBase (DimDecl VName) as
- lookupMTy :: SrcLoc -> QualName Name -> TypeM (QualName VName, MTy)
- lookupImport :: SrcLoc -> FilePath -> TypeM (FilePath, Env)
- localEnv :: Env -> TypeM a -> TypeM a
- data TypeError = TypeError SrcLoc Notes Doc
- 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 :: Pretty a => a -> Notes
- class Monad m => MonadTypeChecker m where
- warn :: Located loc => loc -> Doc -> m ()
- newName :: VName -> m VName
- newID :: 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], StructType, Liftedness)
- lookupMod :: SrcLoc -> QualName Name -> m (QualName VName, Mod)
- lookupVar :: SrcLoc -> QualName Name -> m (QualName VName, PatternType)
- checkNamedDim :: SrcLoc -> QualName Name -> m (QualName VName)
- typeError :: Located loc => loc -> Notes -> Doc -> m a
- checkName :: MonadTypeChecker m => Namespace -> Name -> SrcLoc -> m 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 String Env
- type NameMap = Map (Namespace, Name) (QualName VName)
- data BoundV = BoundV [TypeParam] StructType
- data Mod
- data TypeBinding = TypeAbbr Liftedness [TypeParam] StructType
- data MTy = MTy {}
- anySignedType :: [PrimType]
- anyUnsignedType :: [PrimType]
- anyFloatType :: [PrimType]
- anyNumberType :: [PrimType]
- anyPrimType :: [PrimType]
- data Namespace
- intrinsicsNameMap :: NameMap
- topLevelNameMap :: NameMap
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.
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 (DimDecl VName) as -> TypeBase (DimDecl VName) as Source #
Try to prepend qualifiers to the type names such that they represent how to access the type in some scope.
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
Pretty TypeError Source # | |
MonadError TypeError TypeM Source # | |
Defined in Language.Futhark.TypeChecker.Monad throwError :: TypeError -> TypeM a # catchError :: TypeM a -> (TypeError -> TypeM a) -> TypeM a # |
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 Note
s.
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, bindNameMap, bindVal, checkQualName, lookupType, lookupMod, lookupVar, typeError
warn :: Located loc => loc -> Doc -> m () Source #
newName :: VName -> m VName Source #
newID :: 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], StructType, Liftedness) Source #
lookupMod :: SrcLoc -> QualName Name -> m (QualName VName, Mod) Source #
lookupVar :: SrcLoc -> QualName Name -> m (QualName VName, PatternType) Source #
checkNamedDim :: SrcLoc -> QualName Name -> m (QualName VName) Source #
typeError :: Located loc => loc -> Notes -> Doc -> m a Source #
Instances
MonadTypeChecker TypeM Source # | |
Defined in Language.Futhark.TypeChecker.Monad warn :: Located loc => loc -> Doc -> TypeM () Source # newName :: VName -> TypeM VName Source # newID :: Name -> TypeM VName Source # bindNameMap :: NameMap -> TypeM a -> TypeM a Source # bindVal :: VName -> BoundV -> TypeM a -> TypeM a Source # checkQualName :: Namespace -> QualName Name -> SrcLoc -> TypeM (QualName VName) Source # lookupType :: SrcLoc -> QualName Name -> TypeM (QualName VName, [TypeParam], StructType, Liftedness) Source # lookupMod :: SrcLoc -> QualName Name -> TypeM (QualName VName, Mod) Source # lookupVar :: SrcLoc -> QualName Name -> TypeM (QualName VName, PatternType) Source # checkNamedDim :: SrcLoc -> QualName Name -> TypeM (QualName VName) Source # typeError :: Located loc => loc -> Notes -> Doc -> TypeM a Source # |
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
.
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 String Env Source #
A mapping from import strings 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.
Instances
Eq TypeBinding Source # | |
Defined in Language.Futhark.Semantic (==) :: TypeBinding -> TypeBinding -> Bool # (/=) :: TypeBinding -> TypeBinding -> Bool # | |
Show TypeBinding Source # | |
Defined in Language.Futhark.Semantic showsPrec :: Int -> TypeBinding -> ShowS # show :: TypeBinding -> String # showList :: [TypeBinding] -> ShowS # |
Representation of a module type.
anySignedType :: [PrimType] Source #
All signed integer types.
anyUnsignedType :: [PrimType] Source #
All unsigned 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] # | |
Eq Namespace Source # | |
Ord Namespace Source # | |
Defined in Language.Futhark.Semantic | |
Show Namespace Source # | |
Pretty Namespace Source # | |
intrinsicsNameMap :: NameMap Source #
The NameMap
corresponding to the intrinsics module.
topLevelNameMap :: NameMap Source #
The names that are available in the initial environment.