Copyright | (c) 2013-2016 Galois Inc. |
---|---|
License | BSD3 |
Maintainer | cryptol@galois.com |
Stability | provisional |
Portability | portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Synopsis
- tcModule :: Module Name -> InferInput -> IO (InferOutput TCTopEntity)
- tcExpr :: Expr Name -> InferInput -> IO (InferOutput (Expr, Schema))
- tcDecls :: [TopDecl Name] -> InferInput -> IO (InferOutput ([DeclGroup], Map Name TySyn))
- data InferInput = InferInput {
- inpRange :: Range
- inpVars :: Map Name Schema
- inpTSyns :: Map Name TySyn
- inpNominalTypes :: Map Name NominalType
- inpSignatures :: !(Map Name ModParamNames)
- inpTopModules :: ModName -> Maybe (ModuleG (), IfaceG ())
- inpTopSignatures :: ModName -> Maybe ModParamNames
- inpParams :: !ModParamNames
- inpNameSeeds :: NameSeeds
- inpMonoBinds :: Bool
- inpCallStacks :: Bool
- inpSearchPath :: [FilePath]
- inpPrimNames :: !PrimMap
- inpSupply :: !Supply
- inpSolver :: Solver
- data InferOutput a
- data SolverConfig = SolverConfig {
- solverPath :: FilePath
- solverArgs :: [String]
- solverVerbose :: Int
- solverPreludePath :: [FilePath]
- defaultSolverConfig :: [FilePath] -> SolverConfig
- data NameSeeds
- nameSeeds :: NameSeeds
- data Error
- = KindMismatch (Maybe TypeSource) Kind Kind
- | TooManyTypeParams Int Kind
- | TyVarWithParams
- | TooManyTySynParams Name Int
- | TooFewTyParams Name Int
- | RecursiveTypeDecls [Name]
- | TypeMismatch TypeSource Path Type Type
- | EnumTypeMismatch Type
- | SchemaMismatch Ident Schema Schema
- | RecursiveType TypeSource Path Type Type
- | UnsolvedGoals [Goal]
- | UnsolvableGoals [Goal]
- | UnsolvedDelayedCt DelayedCt
- | UnexpectedTypeWildCard
- | TypeVariableEscaped TypeSource Path Type [TParam]
- | NotForAll TypeSource Path TVar Type
- | TooManyPositionalTypeParams
- | BadParameterKind TParam Kind
- | CannotMixPositionalAndNamedTypeParams
- | UndefinedTypeParameter (Located Ident)
- | RepeatedTypeParameter Ident [Range]
- | AmbiguousSize TVarInfo (Maybe Type)
- | BareTypeApp
- | UndefinedExistVar Name
- | TypeShadowing String Name String
- | MissingModTParam (Located Ident)
- | MissingModVParam (Located Ident)
- | MissingModParam Ident
- | FunctorInstanceMissingArgument Ident
- | FunctorInstanceBadArgument Ident
- | FunctorInstanceMissingName Namespace Ident
- | FunctorInstanceBadBacktick BadBacktickInstance
- | UnsupportedFFIKind TypeSource TParam Kind
- | UnsupportedFFIType TypeSource FFITypeError
- | NestedConstraintGuard Ident
- | DeclarationRequiresSignatureCtrGrd Ident
- | InvalidConstraintGuard Prop
- | InvalidConPat Int Int
- | UncoveredConPat [Name]
- | OverlappingPat (Maybe Ident) [Range]
- | TemporaryError Doc
- data Warning
- ppWarning :: (Range, Warning) -> Doc
- ppError :: (Range, Error) -> Doc
- data WithNames a = WithNames a NameMap
- type NameMap = IntMap String
- ppNamedWarning :: NameMap -> (Range, Warning) -> Doc
- ppNamedError :: NameMap -> (Range, Error) -> Doc
Documentation
tcModule :: Module Name -> InferInput -> IO (InferOutput TCTopEntity) Source #
tcExpr :: Expr Name -> InferInput -> IO (InferOutput (Expr, Schema)) Source #
data InferInput Source #
Information needed for type inference.
InferInput | |
|
data InferOutput a Source #
The results of type inference.
InferFailed NameMap [(Range, Warning)] [(Range, Error)] | We found some errors |
InferOK NameMap [(Range, Warning)] NameSeeds Supply a | Type inference was successful. |
Instances
Show a => Show (InferOutput a) Source # | |
Defined in Cryptol.TypeCheck.Monad showsPrec :: Int -> InferOutput a -> ShowS # show :: InferOutput a -> String # showList :: [InferOutput a] -> ShowS # |
data SolverConfig Source #
SolverConfig | |
|
Instances
defaultSolverConfig :: [FilePath] -> SolverConfig Source #
A default configuration for using Z3, where the solver prelude is expected to be found in the given search path.
This is used for generating various names.
Instances
Generic NameSeeds Source # | |
Show NameSeeds Source # | |
NFData NameSeeds Source # | |
Defined in Cryptol.TypeCheck.Monad | |
type Rep NameSeeds Source # | |
Defined in Cryptol.TypeCheck.Monad type Rep NameSeeds = D1 ('MetaData "NameSeeds" "Cryptol.TypeCheck.Monad" "cryptol-3.1.0-276efOa9Q2aIFSEzDdp2Mp" 'False) (C1 ('MetaCons "NameSeeds" 'PrefixI 'True) (S1 ('MetaSel ('Just "seedTVar") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int) :*: S1 ('MetaSel ('Just "seedGoal") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int))) |
nameSeeds :: NameSeeds Source #
The initial seeds, used when checking a fresh program. XXX: why does this start at 10?
Various errors that might happen during type checking/inference
KindMismatch (Maybe TypeSource) Kind Kind | Expected kind, inferred kind |
TooManyTypeParams Int Kind | Number of extra parameters, kind of result
(which should not be of the form |
TyVarWithParams | A type variable was applied to some arguments. |
TooManyTySynParams Name Int | Type-synonym, number of extra params |
TooFewTyParams Name Int | Who is missing params, number of missing params |
RecursiveTypeDecls [Name] | The type synonym declarations are recursive |
TypeMismatch TypeSource Path Type Type | Expected type, inferred type |
EnumTypeMismatch Type | Expected an enum type, but inferred the supplied |
SchemaMismatch Ident Schema Schema | Name of module parameter, expected scehema, actual schema. This may happen when instantiating modules. |
RecursiveType TypeSource Path Type Type | Unification results in a recursive type |
UnsolvedGoals [Goal] | A constraint that we could not solve, usually because there are some left-over variables that we could not infer. |
UnsolvableGoals [Goal] | A constraint that we could not solve and we know it is impossible to do it. |
UnsolvedDelayedCt DelayedCt | A constraint (with context) that we could not solve |
UnexpectedTypeWildCard | Type wild cards are not allowed in this context (e.g., definitions of type synonyms). |
TypeVariableEscaped TypeSource Path Type [TParam] | Unification variable depends on quantified variables that are not in scope. |
NotForAll TypeSource Path TVar Type | Quantified type variables (of kind *) need to match the given type, so it does not work for all types. |
TooManyPositionalTypeParams | Too many positional type arguments, in an explicit type instantiation |
BadParameterKind TParam Kind | Kind other than |
CannotMixPositionalAndNamedTypeParams | |
UndefinedTypeParameter (Located Ident) | |
RepeatedTypeParameter Ident [Range] | |
AmbiguousSize TVarInfo (Maybe Type) | Could not determine the value of a numeric type variable, but we know it must be at least as large as the given type (or unconstrained, if Nothing). |
BareTypeApp | Bare expression of the form `{_} |
UndefinedExistVar Name | |
TypeShadowing String Name String | |
MissingModTParam (Located Ident) | |
MissingModVParam (Located Ident) | |
MissingModParam Ident | |
FunctorInstanceMissingArgument Ident | |
FunctorInstanceBadArgument Ident | |
FunctorInstanceMissingName Namespace Ident | |
FunctorInstanceBadBacktick BadBacktickInstance | |
UnsupportedFFIKind TypeSource TParam Kind | Kind is not supported for FFI |
UnsupportedFFIType TypeSource FFITypeError | Type is not supported for FFI |
NestedConstraintGuard Ident | Constraint guards may only apper at the top-level |
DeclarationRequiresSignatureCtrGrd Ident | All declarataions in a recursive group involving constraint guards should have signatures |
InvalidConstraintGuard Prop | The given constraint may not be used as a constraint guard |
InvalidConPat Int Int | Bad constructor pattern. 1) Number of parameters we have, 2) Number of parameters we need. |
UncoveredConPat [Name] | A |
OverlappingPat (Maybe Ident) [Range] | Overlapping patterns in a case |
TemporaryError Doc | This is for errors that don't fit other cateogories. We should not use it much, and is generally to be used for transient errors, which are due to incomplete implementation. |
Instances
DefaultingKind (TParam Name) Kind | |
DefaultingWildType Kind | |
DefaultingTo !TVarInfo Type | |
NonExhaustivePropGuards Name |
Instances
This packages together a type with some names to be used to display the variables. It is used for pretty printing types.
Instances
PP (WithNames Decl) Source # | |
PP (WithNames DeclDef) Source # | |
PP (WithNames DeclGroup) Source # | |
PP (WithNames Expr) Source # | |
PP (WithNames Match) Source # | |
PP n => PP (WithNames (ModuleG n)) Source # | |
PP (WithNames TCTopEntity) Source # | |
Defined in Cryptol.TypeCheck.AST | |
PP (WithNames Error) Source # | |
PP (WithNames Warning) Source # | |
PP (WithNames FFITypeError) Source # | |
Defined in Cryptol.TypeCheck.FFI.Error | |
PP (WithNames FFITypeErrorReason) Source # | |
Defined in Cryptol.TypeCheck.FFI.Error | |
PP (WithNames DelayedCt) Source # | |
PP (WithNames Goal) Source # | |
PP (WithNames Subst) Source # | |
PP (WithNames NominalType) Source # | |
Defined in Cryptol.TypeCheck.Type | |
PP (WithNames Schema) Source # | |
PP (WithNames TParam) Source # | |
PP (WithNames TVar) Source # | |
PP (WithNames TySyn) Source # | |
PP (WithNames Type) Source # | The precedence levels used by this pretty-printing instance correspond with parser non-terminals as follows:
|