libcspm-0.1.2: A library providing a parser, type checker and evaluator for CSPM.

CSPM

Contents

Synopsis

Documentation

CSPM Monad

data CSPMSession Source

A CSPMSession represents the internal states of all the various components.

Instances

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.

Instances

withSession :: CSPMMonad m => (CSPMSession -> m a) -> m aSource

A basic implementation of the monad

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

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.