| Safe Haskell | Trustworthy |
|---|---|
| Language | Haskell2010 |
Futhark.TypeCheck
Contents
Description
The type checker checks whether the program is type-consistent.
Synopsis
- checkProg :: Checkable lore => Prog (Aliases lore) -> Either (TypeError lore) ()
- data TypeError lore = Error [String] (ErrorCase lore)
- data ErrorCase lore
- = TypeError String
- | UnexpectedType (Exp lore) Type [Type]
- | ReturnTypeError Name [ExtType] [ExtType]
- | DupDefinitionError Name
- | DupParamError Name VName
- | DupPatternError VName
- | InvalidPatternError (Pattern (Aliases lore)) [ExtType] (Maybe String)
- | UnknownVariableError VName
- | UnknownFunctionError Name
- | ParameterMismatch (Maybe Name) [Type] [Type]
- | SlicingError Int Int
- | BadAnnotation String Type Type
- | ReturnAliased Name VName
- | UniqueReturnAliased Name
- | NotAnArray VName Type
- | PermutationError [Int] Int (Maybe VName)
- data TypeM lore a
- bad :: ErrorCase lore -> TypeM lore a
- context :: String -> TypeM lore a -> TypeM lore a
- message :: Pretty a => String -> a -> String
- class (ASTLore lore, CanBeAliased (Op lore), CheckableOp lore) => Checkable lore where
- checkExpLore :: ExpDec lore -> TypeM lore ()
- checkBodyLore :: BodyDec lore -> TypeM lore ()
- checkFParamLore :: VName -> FParamInfo lore -> TypeM lore ()
- checkLParamLore :: VName -> LParamInfo lore -> TypeM lore ()
- checkLetBoundLore :: VName -> LetDec lore -> TypeM lore ()
- checkRetType :: [RetType lore] -> TypeM lore ()
- matchPattern :: Pattern (Aliases lore) -> Exp (Aliases lore) -> TypeM lore ()
- primFParam :: VName -> PrimType -> TypeM lore (FParam (Aliases lore))
- matchReturnType :: [RetType lore] -> Result -> TypeM lore ()
- matchBranchType :: [BranchType lore] -> Body (Aliases lore) -> TypeM lore ()
- matchLoopResult :: [FParam (Aliases lore)] -> [FParam (Aliases lore)] -> [SubExp] -> TypeM lore ()
- class ASTLore lore => CheckableOp lore where
- checkOp :: OpWithAliases (Op lore) -> TypeM lore ()
- lookupVar :: VName -> TypeM lore (NameInfo (Aliases lore))
- lookupAliases :: Checkable lore => VName -> TypeM lore Names
- checkOpWith :: (OpWithAliases (Op lore) -> TypeM lore ()) -> TypeM lore a -> TypeM lore a
- require :: Checkable lore => [Type] -> SubExp -> TypeM lore ()
- requireI :: Checkable lore => [Type] -> VName -> TypeM lore ()
- requirePrimExp :: Checkable lore => PrimType -> PrimExp VName -> TypeM lore ()
- checkSubExp :: Checkable lore => SubExp -> TypeM lore Type
- checkExp :: Checkable lore => Exp (Aliases lore) -> TypeM lore ()
- checkStms :: Checkable lore => Stms (Aliases lore) -> TypeM lore a -> TypeM lore a
- checkStm :: Checkable lore => Stm (Aliases lore) -> TypeM lore a -> TypeM lore a
- checkType :: Checkable lore => TypeBase Shape u -> TypeM lore ()
- checkExtType :: Checkable lore => TypeBase ExtShape u -> TypeM lore ()
- matchExtPattern :: Checkable lore => Pattern (Aliases lore) -> [ExtType] -> TypeM lore ()
- matchExtBranchType :: Checkable lore => [ExtType] -> Body (Aliases lore) -> TypeM lore ()
- argType :: Arg -> Type
- argAliases :: Arg -> Names
- noArgAliases :: Arg -> Arg
- checkArg :: Checkable lore => SubExp -> TypeM lore Arg
- checkSOACArrayArgs :: Checkable lore => SubExp -> [VName] -> TypeM lore [Arg]
- checkLambda :: Checkable lore => Lambda (Aliases lore) -> [Arg] -> TypeM lore ()
- checkBody :: Checkable lore => Body (Aliases lore) -> TypeM lore [Names]
- consume :: Checkable lore => Names -> TypeM lore ()
- consumeOnlyParams :: [(VName, Names)] -> TypeM lore a -> TypeM lore a
- binding :: Checkable lore => Scope (Aliases lore) -> TypeM lore a -> TypeM lore a
- alternative :: TypeM lore a -> TypeM lore b -> TypeM lore (a, b)
Interface
checkProg :: Checkable lore => Prog (Aliases lore) -> Either (TypeError lore) () Source #
Type check a program containing arbitrary type information, yielding either a type error or a program with complete type information.
A type error.
Information about an error during type checking. The Show
instance for this type produces a human-readable description.
Constructors
Extensionality
The type checker runs in this monad.
context :: String -> TypeM lore a -> TypeM lore a Source #
Add information about what is being type-checked to the current
context. Liberal use of this combinator makes it easier to track
type errors, as the strings are added to type errors signalled via
bad.
class (ASTLore lore, CanBeAliased (Op lore), CheckableOp lore) => Checkable lore where Source #
The class of lores that can be type-checked.
Minimal complete definition
Nothing
Methods
checkExpLore :: ExpDec lore -> TypeM lore () Source #
checkBodyLore :: BodyDec lore -> TypeM lore () Source #
checkFParamLore :: VName -> FParamInfo lore -> TypeM lore () Source #
default checkFParamLore :: FParamInfo lore ~ DeclType => VName -> FParamInfo lore -> TypeM lore () Source #
checkLParamLore :: VName -> LParamInfo lore -> TypeM lore () Source #
default checkLParamLore :: LParamInfo lore ~ Type => VName -> LParamInfo lore -> TypeM lore () Source #
checkLetBoundLore :: VName -> LetDec lore -> TypeM lore () Source #
checkRetType :: [RetType lore] -> TypeM lore () Source #
default checkRetType :: RetType lore ~ DeclExtType => [RetType lore] -> TypeM lore () Source #
matchPattern :: Pattern (Aliases lore) -> Exp (Aliases lore) -> TypeM lore () Source #
primFParam :: VName -> PrimType -> TypeM lore (FParam (Aliases lore)) Source #
default primFParam :: FParamInfo lore ~ DeclType => VName -> PrimType -> TypeM lore (FParam (Aliases lore)) Source #
matchReturnType :: [RetType lore] -> Result -> TypeM lore () Source #
default matchReturnType :: RetType lore ~ DeclExtType => [RetType lore] -> Result -> TypeM lore () Source #
matchBranchType :: [BranchType lore] -> Body (Aliases lore) -> TypeM lore () Source #
default matchBranchType :: BranchType lore ~ ExtType => [BranchType lore] -> Body (Aliases lore) -> TypeM lore () Source #
matchLoopResult :: [FParam (Aliases lore)] -> [FParam (Aliases lore)] -> [SubExp] -> TypeM lore () Source #
Instances
class ASTLore lore => CheckableOp lore where Source #
Methods
checkOp :: OpWithAliases (Op lore) -> TypeM lore () Source #
Used at top level; can be locally changed with checkOpWith.
Instances
| CheckableOp Seq Source # | |
Defined in Futhark.IR.Seq | |
| CheckableOp SOACS Source # | |
Defined in Futhark.IR.SOACS | |
| CheckableOp MCMem Source # | |
Defined in Futhark.IR.MCMem | |
| CheckableOp MC Source # | |
Defined in Futhark.IR.MC | |
| CheckableOp SeqMem Source # | |
Defined in Futhark.IR.SeqMem | |
| CheckableOp Kernels Source # | |
Defined in Futhark.IR.Kernels | |
| CheckableOp KernelsMem Source # | |
Defined in Futhark.IR.KernelsMem Methods checkOp :: OpWithAliases (Op KernelsMem) -> TypeM KernelsMem () Source # | |
checkOpWith :: (OpWithAliases (Op lore) -> TypeM lore ()) -> TypeM lore a -> TypeM lore a Source #
Checkers
require :: Checkable lore => [Type] -> SubExp -> TypeM lore () Source #
require ts se causes a '(TypeError vn)' if the type of se is
not a subtype of one of the types in ts.
requireI :: Checkable lore => [Type] -> VName -> TypeM lore () Source #
Variant of require working on variable names.
argAliases :: Arg -> Names Source #
Remove all aliases from the Arg.
noArgAliases :: Arg -> Arg Source #
consume :: Checkable lore => Names -> TypeM lore () Source #
Proclaim that we have written to the given variables.
consumeOnlyParams :: [(VName, Names)] -> TypeM lore a -> TypeM lore a Source #
Permit consumption of only the specified names. If one of these names is consumed, the consumption will be rewritten to be a consumption of the corresponding alias set. Consumption of anything else will result in a type error.