ddc-driver-0.4.3.1: Disciplined Disciple Compiler top-level driver.

Safe HaskellNone
LanguageHaskell98

DDC.Driver.Command.Check

Contents

Synopsis

Checking modules.

cmdCheckFromFile Source #

Arguments

:: Config

Driver config.

-> Store

Interface store.

-> FilePath

Module file path.

-> ExceptT String IO () 

Parse and type-check a core module from a file, printing any errors to stdout.

This function handle fragments of Disciple Core, as well as Source Tetra modules. The language to use is determined by inspecting the file name extension.

cmdCheckSourceTetraFromFile Source #

Arguments

:: Config

Driver config.

-> Store

Interface store.

-> FilePath

Module file path.

-> ExceptT String IO () 

Check a Disciple Source Tetra module from a file.

cmdCheckSourceTetraFromString Source #

Arguments

:: Config

Driver config.

-> Store

Interface store

-> Source

Source of the code.

-> String

Program module text.

-> ExceptT String IO () 

Check a Disciple Source Tetra module from a string. Any errors are thrown in the ExceptT monad.

cmdCheckCoreFromFile Source #

Arguments

:: Config

Driver config.

-> Language

Core language definition.

-> FilePath

Module file path.

-> ExceptT String IO () 

Check some fragment of Disciple core from a file.

cmdCheckCoreFromString Source #

Arguments

:: (Ord n, Show n, Pretty n, Pretty (err (AnTEC SourcePos n))) 
=> Fragment n err

Language fragment.

-> Source

Source of the program text.

-> String

Program text.

-> Mode n

Type checker mode.

-> ExceptT String IO (Module (AnTEC SourcePos n) n) 

Parse and type-check a core module from a string.

Checking types.

cmdShowType :: Language -> Universe -> Source -> String -> IO () Source #

Show the type of a type in the given universe.

cmdTypeEquiv :: Language -> Source -> String -> IO () Source #

Check if two types are equivlant.

cmdParseCheckType Source #

Arguments

:: (Ord n, Show n, Pretty n, Pretty (err (AnTEC SourcePos n))) 
=> Fragment n err

Language fragment.

-> Universe

Universe this type is supposed to be in.

-> Source

Source of the program text.

-> String

Program text.

-> IO (Maybe (Type n, Kind n)) 

Parse a core spec, and return its kind.

Checking expressions.

data Mode n :: * -> * #

What mode we're performing type checking/inference in.

Constructors

Recon

Reconstruct the type of the expression, requiring type annotations on parameters as well as type applications to already be present.

Synth [Exists n]

The ascending smoke of incense.

Synthesise the type of the expression, producing unification variables for bidirectional type inference.

Any new unification variables introduced may be used to define the given existentials, so the need to be declared outside their scopes. If the list is empty we can add new variables to the inner most scope.

Check (Type n)

The descending tongue of flame. Check the type of an expression against this expected type, and unify expected types into unification variables for bidirecional type inference.

Instances

Eq n => Eq (Mode n) 

Methods

(==) :: Mode n -> Mode n -> Bool #

(/=) :: Mode n -> Mode n -> Bool #

Show n => Show (Mode n) 

Methods

showsPrec :: Int -> Mode n -> ShowS #

show :: Mode n -> String #

showList :: [Mode n] -> ShowS #

(Eq n, Pretty n) => Pretty (Mode n) 

Associated Types

data PrettyMode (Mode n) :: * #

Methods

pprDefaultMode :: PrettyMode (Mode n) #

ppr :: Mode n -> Doc #

pprPrec :: Int -> Mode n -> Doc #

pprModePrec :: PrettyMode (Mode n) -> Int -> Mode n -> Doc #

cmdShowSpec Source #

Arguments

:: Language

Language fragment.

-> ShowSpecMode

What part of the type to show.

-> Bool

Type checker mode, Synth(True) or Recon(False)

-> Bool

Whether to display type checker trace.

-> Source

Source of the program text.

-> String

Program text.

-> IO () 

Show the spec of an expression.

cmdExpRecon :: Language -> Source -> String -> IO () Source #

Check expression and reconstruct type annotations on binders.

cmdParseCheckExp Source #

Arguments

:: (Ord n, Show n, Pretty n, Pretty (err (AnTEC SourcePos n))) 
=> Fragment n err

The current language fragment.

-> ModuleMap (AnTEC () n) n

Current modules

-> Mode n

Type checker mode.

-> Bool

Print type checker trace.

-> Bool

Allow partial application of primitives.

-> Source

Where this expression was sourced from.

-> String

Text to parse.

-> IO (Maybe (Exp (AnTEC SourcePos n) n), Maybe CheckTrace) 

Parse the given core expression, and return it, along with its type, effect and closure.

If the expression had a parse error, undefined vars, or type error then print this to the console.

We include a flag to override the language profile to allow partially applied primitives. Although a paticular evaluator (or backend) may not support partially applied primitives, we want to accept them if we are only loading an expression to check its type.

Checking witnesses.

cmdShowWType :: Language -> Source -> String -> IO () Source #

Show the type of a witness.