ddc-core-0.4.3.1: Disciplined Disciple Compiler core language and type checker.

Safe HaskellNone
LanguageHaskell98

DDC.Core.Load

Contents

Description

"Loading" refers to the combination of parsing and type checking. This is the easiest way to turn source tokens into a type-checked abstract syntax tree.

Synopsis

Documentation

data AnTEC a n Source #

The type checker adds this annotation to every node in the AST, giving its type, effect and closure.

Constructors

AnTEC 

Instances

(Show a, Show n) => Show (AnTEC a n) Source # 

Methods

showsPrec :: Int -> AnTEC a n -> ShowS #

show :: AnTEC a n -> String #

showList :: [AnTEC a n] -> ShowS #

(NFData a, NFData n) => NFData (AnTEC a n) Source # 

Methods

rnf :: AnTEC a n -> () #

Pretty (AnTEC a n) Source # 

Associated Types

data PrettyMode (AnTEC a n) :: * Source #

Methods

pprDefaultMode :: PrettyMode (AnTEC a n) Source #

ppr :: AnTEC a n -> Doc Source #

pprPrec :: Int -> AnTEC a n -> Doc Source #

pprModePrec :: PrettyMode (AnTEC a n) -> Int -> AnTEC a n -> Doc Source #

data Error n err Source #

Things that can go wrong when loading a core thing.

Instances

(Eq n, Show n, Pretty n, Pretty (err (AnTEC SourcePos n))) => Pretty (Error n err) Source # 

Associated Types

data PrettyMode (Error n err) :: * Source #

Methods

pprDefaultMode :: PrettyMode (Error n err) Source #

ppr :: Error n err -> Doc Source #

pprPrec :: Int -> Error n err -> Doc Source #

pprModePrec :: PrettyMode (Error n err) -> Int -> Error n err -> Doc Source #

data Mode n Source #

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) Source # 

Methods

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

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

Show n => Show (Mode n) Source # 

Methods

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

show :: Mode n -> String #

showList :: [Mode n] -> ShowS #

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

Associated Types

data PrettyMode (Mode n) :: * Source #

Methods

pprDefaultMode :: PrettyMode (Mode n) Source #

ppr :: Mode n -> Doc Source #

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

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

data CheckTrace Source #

Human readable trace of the type checker.

Constructors

CheckTrace 

Fields

Loading modules

loadModuleFromFile Source #

Arguments

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

Language fragment definition.

-> FilePath

File containing source code.

-> Mode n

Type checker mode.

-> IO (Either (Error n err) (Module (AnTEC SourcePos n) n), Maybe CheckTrace) 

Parse and type check a core module from a file.

loadModuleFromString Source #

Arguments

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

Language fragment definition.

-> FilePath

Path to source file for error messages.

-> Int

Starting line number for error messages.

-> Mode n

Type checker mode.

-> String

Program text.

-> (Either (Error n err) (Module (AnTEC SourcePos n) n), Maybe CheckTrace) 

Parse and type check a core module from a string.

loadModuleFromTokens Source #

Arguments

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

Language fragment definition.

-> FilePath

Path to source file for error messages.

-> Mode n

Type checker mode.

-> [Located (Token n)]

Source tokens.

-> (Either (Error n err) (Module (AnTEC SourcePos n) n), Maybe CheckTrace) 

Parse and type check a core module from some tokens.

Loading expressions

loadExpFromString Source #

Arguments

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

Language fragment definition.

-> Map ModuleName (Module (AnTEC () n) n)

Other modules currently in scope. We add their exports to the environment.

-> FilePath

Path to source file for error messages.

-> Mode n

Type checker mode.

-> String

Source string.

-> (Either (Error n err) (Exp (AnTEC SourcePos n) n), Maybe CheckTrace) 

Parse and type-check and expression from a string.

loadExpFromTokens Source #

Arguments

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

Language fragment definition.

-> Map ModuleName (Module (AnTEC () n) n)

Other modules currently in scope. We add their exports to the environment.

-> FilePath

Path to source file for error messages.

-> Mode n

Type checker mode.

-> [Located (Token n)]

Source tokens.

-> (Either (Error n err) (Exp (AnTEC SourcePos n) n), Maybe CheckTrace) 

Parse and check an expression returning it along with its spec, effect and closure

Loading types

loadTypeFromString Source #

Arguments

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

Language fragment definition.

-> Universe

Universe this type is supposed to be in.

-> FilePath

Path to source file for error messages.

-> String

Source string.

-> Either (Error n err) (Type n, Kind n) 

Parse and check a type from a string, returning it along with its kind.

loadTypeFromTokens Source #

Arguments

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

Language fragment definition.

-> Universe

Universe this type is supposed to be in.

-> FilePath

Path to source file for error messages.

-> [Located (Token n)]

Source tokens.

-> Either (Error n err) (Type n, Kind n) 

Parse and check a type from some tokens, returning it along with its kind.

Loading witnesses

loadWitnessFromString Source #

Arguments

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

Language fragment profile.

-> FilePath

Path to source file for error messages.

-> String

Source string.

-> Either (Error n err) (Witness (AnT SourcePos n) n, Type n) 

Parse and check a witness from a string, returning it along with its kind.

loadWitnessFromTokens Source #

Arguments

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

Language fragment profile.

-> FilePath

Path to source file for error messages.

-> [Located (Token n)]

Source tokens.

-> Either (Error n err) (Witness (AnT SourcePos n) n, Type n) 

Parse and check a witness from some tokens, returning it along with its type.