- module CSPM.DataStructures.Names
- module CSPM.DataStructures.Syntax
- module CSPM.DataStructures.Types
- data CSPMSession
- newCSPMSession :: MonadIO m => m CSPMSession
- class MonadIO m => CSPMMonad m where
- getSession :: m CSPMSession
- setSession :: CSPMSession -> m ()
- handleWarnings :: [ErrorMessage] -> m ()
- withSession :: CSPMMonad m => (CSPMSession -> m a) -> m a
- type CSPM = StateT CSPMSession IO
- unCSPM :: CSPMSession -> CSPM a -> IO (a, CSPMSession)
- parseStringAsFile :: CSPMMonad m => String -> m [PModule]
- parseFile :: CSPMMonad m => FilePath -> m [PModule]
- parseInteractiveStmt :: CSPMMonad m => String -> m PInteractiveStmt
- parseExpression :: CSPMMonad m => String -> m PExp
- typeCheckFile :: CSPMMonad m => [PModule] -> m [TCModule]
- typeCheckInteractiveStmt :: CSPMMonad m => PInteractiveStmt -> m TCInteractiveStmt
- typeCheckExpression :: CSPMMonad m => PExp -> m TCExp
- ensureExpressionIsOfType :: CSPMMonad m => Type -> PExp -> m TCExp
- dependenciesOfExp :: CSPMMonad m => TCExp -> m [Name]
- typeOfExpression :: CSPMMonad m => PExp -> m Type
- evaluateExp :: CSPMMonad m => TCExp -> m Value
- bindFile :: CSPMMonad m => [TCModule] -> m ()
- bindDeclaration :: CSPMMonad m => TCDecl -> m ()
- getBoundNames :: CSPMMonad m => m [Name]
- getLibCSPMVersion :: Version
Documentation
module CSPM.DataStructures.Names
module CSPM.DataStructures.Syntax
module CSPM.DataStructures.Types
CSPM Monad
data CSPMSession Source
A CSPMSession
represents the internal states of all the various
components.
newCSPMSession :: MonadIO m => m CSPMSessionSource
Create a new CSPMSession
.
class MonadIO m => CSPMMonad m whereSource
The CSPMMonad is the main monad in which all functions must be called.
Whilst there is a build in representation (see CSPM
) it is recommended
that you define an instance of CSPMMonad over whatever monad you use.
getSession :: m CSPMSessionSource
setSession :: CSPMSession -> m ()Source
handleWarnings :: [ErrorMessage] -> m ()Source
withSession :: CSPMMonad m => (CSPMSession -> m a) -> m aSource
A basic implementation of the monad
type CSPM = StateT CSPMSession IOSource
unCSPM :: CSPMSession -> CSPM a -> IO (a, CSPMSession)Source
Parser API
parseStringAsFile :: CSPMMonad m => String -> m [PModule]Source
Parses a string, treating it as though it were a file. Throws a
SourceError
on any parse error.
parseFile :: CSPMMonad m => FilePath -> m [PModule]Source
Parse a file fp
. Throws a SourceError
on any parse error.
parseInteractiveStmt :: CSPMMonad m => String -> m PInteractiveStmtSource
Parses an InteractiveStmt
. Throws a SourceError
on any parse error.
parseExpression :: CSPMMonad m => String -> m PExpSource
Parses an Exp
. Throws a SourceError
on any parse error.
Type Checker API
typeCheckFile :: CSPMMonad m => [PModule] -> m [TCModule]Source
Type checks a file, also desugaring it. Throws a SourceError
if an error is encountered and will call handleWarnings
typeCheckInteractiveStmt :: CSPMMonad m => PInteractiveStmt -> m TCInteractiveStmtSource
Type checks a InteractiveStmt
.
typeCheckExpression :: CSPMMonad m => PExp -> m TCExpSource
dependenciesOfExp :: CSPMMonad m => TCExp -> m [Name]Source
typeOfExpression :: CSPMMonad m => PExp -> m TypeSource
Gets the type of the expression in the current context.
Evaluator API
evaluateExp :: CSPMMonad m => TCExp -> m ValueSource
Evaluates the expression in the current context.
bindFile :: CSPMMonad m => [TCModule] -> m ()Source
Binds all the declarations that are in a particular file.
bindDeclaration :: CSPMMonad m => TCDecl -> m ()Source
Takes a declaration and adds it to the current environment.
getBoundNames :: CSPMMonad m => m [Name]Source
Get a list of currently bound names in the environment.
Misc functions
getLibCSPMVersion :: VersionSource
Return the version of libcspm that is being used.