Safe Haskell | None |
---|---|
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 -> Either TypeError (a, Warnings, VNameSource)
- askEnv :: TypeM Env
- askRootEnv :: TypeM Env
- localTmpEnv :: Env -> TypeM a -> TypeM a
- checkQualNameWithEnv :: Namespace -> QualName Name -> SrcLoc -> TypeM (Env, QualName VName)
- bindSpaced :: MonadTypeChecker m => [(Namespace, Name)] -> m a -> m a
- qualifyTypeVars :: ASTMappable t => Env -> [VName] -> [VName] -> t -> t
- getType :: TypeBase dim as -> Either ([(Maybe VName, TypeBase dim as)], TypeBase dim as) (TypeBase dim as)
- data TypeError = TypeError SrcLoc String
- unexpectedType :: MonadTypeChecker m => SrcLoc -> TypeBase () () -> [TypeBase () ()] -> m a
- undefinedType :: MonadTypeChecker m => SrcLoc -> QualName Name -> m a
- unappliedFunctor :: MonadTypeChecker m => SrcLoc -> m a
- unknownVariableError :: MonadTypeChecker m => Namespace -> QualName Name -> SrcLoc -> m a
- underscoreUse :: MonadTypeChecker m => SrcLoc -> QualName Name -> m a
- functionIsNotValue :: MonadTypeChecker m => SrcLoc -> QualName Name -> m a
- data BreadCrumb
- = MatchingTypes (TypeBase () ()) (TypeBase () ())
- | MatchingFields Name
- class Monad m => MonadBreadCrumbs m where
- breadCrumb :: BreadCrumb -> m a -> m a
- getBreadCrumbs :: m [BreadCrumb]
- typeError :: (MonadError TypeError m, MonadBreadCrumbs m) => SrcLoc -> String -> m a
- class MonadError TypeError m => MonadTypeChecker m where
- warn :: SrcLoc -> String -> m ()
- newName :: VName -> m VName
- newID :: Name -> m VName
- bindNameMap :: NameMap -> m a -> m a
- localEnv :: Env -> 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)
- lookupMTy :: SrcLoc -> QualName Name -> m (QualName VName, MTy)
- lookupImport :: SrcLoc -> FilePath -> m (FilePath, Env)
- lookupVar :: SrcLoc -> QualName Name -> m (QualName VName, CompType)
- checkName :: MonadTypeChecker m => Namespace -> Name -> SrcLoc -> m VName
- badOnLeft :: MonadTypeChecker m => Either TypeError a -> m a
- quote :: String -> String
- 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]
- anyIntType :: [PrimType]
- anyFloatType :: [PrimType]
- anyNumberType :: [PrimType]
- anyPrimType :: [PrimType]
- data Namespace
- intrinsicsNameMap :: NameMap
- topLevelNameMap :: NameMap
- ppSpace :: Namespace -> String
Documentation
The type checker runs in this monad.
Instances
runTypeM :: Env -> ImportTable -> ImportName -> VNameSource -> TypeM a -> Either TypeError (a, Warnings, VNameSource) Source #
askRootEnv :: TypeM Env Source #
checkQualNameWithEnv :: Namespace -> QualName Name -> SrcLoc -> TypeM (Env, QualName VName) Source #
bindSpaced :: MonadTypeChecker m => [(Namespace, Name)] -> m a -> m a Source #
qualifyTypeVars :: ASTMappable t => Env -> [VName] -> [VName] -> t -> t Source #
getType :: TypeBase dim as -> Either ([(Maybe VName, TypeBase dim as)], TypeBase dim as) (TypeBase dim as) Source #
Extract from a type either a function type comprising a list of parameter types and a return type, or a first-order type.
Information about an error during type checking. The Show
instance for this type produces a human-readable description.
Instances
Show TypeError Source # | |
MonadError TypeError TypeM Source # | |
Defined in Language.Futhark.TypeChecker.Monad throwError :: TypeError -> TypeM a # catchError :: TypeM a -> (TypeError -> TypeM a) -> TypeM a # |
unexpectedType :: MonadTypeChecker m => SrcLoc -> TypeBase () () -> [TypeBase () ()] -> m a Source #
undefinedType :: MonadTypeChecker m => SrcLoc -> QualName Name -> m a Source #
unappliedFunctor :: MonadTypeChecker m => SrcLoc -> m a Source #
unknownVariableError :: MonadTypeChecker m => Namespace -> QualName Name -> SrcLoc -> m a Source #
underscoreUse :: MonadTypeChecker m => SrcLoc -> QualName Name -> m a Source #
functionIsNotValue :: MonadTypeChecker m => SrcLoc -> QualName Name -> m a Source #
data BreadCrumb Source #
A piece of information that describes what process the type checker currently performing. This is used to give better error messages.
MatchingTypes (TypeBase () ()) (TypeBase () ()) | |
MatchingFields Name |
Instances
Show BreadCrumb Source # | |
Defined in Language.Futhark.TypeChecker.Monad showsPrec :: Int -> BreadCrumb -> ShowS # show :: BreadCrumb -> String # showList :: [BreadCrumb] -> ShowS # |
class Monad m => MonadBreadCrumbs m where Source #
Tracking breadcrumbs to give a kind of "stack trace" in errors.
Nothing
breadCrumb :: BreadCrumb -> m a -> m a Source #
getBreadCrumbs :: m [BreadCrumb] Source #
typeError :: (MonadError TypeError m, MonadBreadCrumbs m) => SrcLoc -> String -> m a Source #
class MonadError TypeError m => MonadTypeChecker m where Source #
warn :: SrcLoc -> String -> m () Source #
newName :: VName -> m VName Source #
newID :: Name -> m VName Source #
bindNameMap :: NameMap -> m a -> m a Source #
localEnv :: Env -> 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 #
lookupMTy :: SrcLoc -> QualName Name -> m (QualName VName, MTy) Source #
lookupImport :: SrcLoc -> FilePath -> m (FilePath, Env) Source #
lookupVar :: SrcLoc -> QualName Name -> m (QualName VName, CompType) Source #
Instances
MonadTypeChecker TypeM Source # | |
Defined in Language.Futhark.TypeChecker.Monad warn :: SrcLoc -> String -> TypeM () Source # newName :: VName -> TypeM VName Source # newID :: Name -> TypeM VName Source # bindNameMap :: NameMap -> TypeM a -> TypeM a Source # localEnv :: Env -> 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 # lookupMTy :: SrcLoc -> QualName Name -> TypeM (QualName VName, MTy) Source # lookupImport :: SrcLoc -> FilePath -> TypeM (FilePath, Env) Source # lookupVar :: SrcLoc -> QualName Name -> TypeM (QualName VName, CompType) Source # |
quote :: String -> String Source #
Enclose a string in the prefered quotes used in error messages. These are picked to not collide with characters permitted in identifiers.
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 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 #
anyUnsignedType :: [PrimType] Source #
anyIntType :: [PrimType] Source #
anyFloatType :: [PrimType] Source #
anyNumberType :: [PrimType] Source #
anyPrimType :: [PrimType] Source #
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 # | |