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

Safe HaskellNone

DDC.Core.Load

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

Typeable2 AnTEC 
(Show a, Show n) => Show (AnTEC a n) 
Pretty (AnTEC a n) 
(NFData a, NFData n) => NFData (AnTEC a n) 

data Error n Source

Things that can go wrong when loading a core thing.

Instances

Show n => Show (Error n) 
(Eq n, Show n, Pretty n) => Pretty (Error n) 

loadModuleFromFileSource

Arguments

:: (Eq n, Ord n, Show n, Pretty n) 
=> Profile n

Language fragment profile.

-> (String -> [Token (Tok n)])

Function to lex the source file.

-> FilePath

File containing source code.

-> IO (Either (Error n) (Module (AnTEC SourcePos n) n)) 

Parse and type check a core module from a file.

loadModuleFromStringSource

Arguments

:: (Eq n, Ord n, Show n, Pretty n) 
=> Profile n

Language fragment profile.

-> (String -> [Token (Tok n)])

Function to lex the source file.

-> FilePath

Path to source file for error messages.

-> String

Program text.

-> Either (Error n) (Module (AnTEC SourcePos n) n) 

Parse and type check a core module from a string.

loadModuleFromTokensSource

Arguments

:: (Eq n, Ord n, Show n, Pretty n) 
=> Profile n

Language fragment profile.

-> FilePath

Path to source file for error messages.

-> [Token (Tok n)]

Source tokens.

-> Either (Error n) (Module (AnTEC SourcePos n) n) 

Parse and type check a core module.

loadExpSource

Arguments

:: (Eq n, Ord n, Show n, Pretty n) 
=> Profile n

Language fragment profile.

-> 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.

-> [Token (Tok n)]

Source tokens.

-> Either (Error n) (Exp (AnTEC SourcePos n) n) 

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

loadTypeSource

Arguments

:: (Eq n, Ord n, Show n, Pretty n) 
=> Profile n

Language fragment profile.

-> FilePath

Path to source file for error messages.

-> [Token (Tok n)]

Source tokens.

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

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

loadWitnessSource

Arguments

:: (Eq n, Ord n, Show n, Pretty n) 
=> Profile n

Language fragment profile.

-> FilePath

Path to source file for error messages.

-> [Token (Tok n)]

Source tokens.

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

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