LicenseGPL-3
Maintainerjaredforthdev@gmail.com
Stabilityexperimental
Safe HaskellSafe

Scheme.Parser

Description

 

Synopsis

Documentation

symbol :: Parser Char #

Define a parser that recognizes allowed symbols in Scheme

readExpr :: String -> ThrowsError LispVal #

Define a function to call parser and handle errors

spaces :: Parser () #

Ignore spaces when parsing input

data LispVal #

A datatype that can hold any Lisp value

Constructors

Atom String 
List [LispVal] 
DottedList [LispVal] LispVal 
Number Integer 
String String 
Bool Bool 
PrimitiveFunc ([LispVal] -> ThrowsError LispVal) 
Func 

Fields

IOFunc ([LispVal] -> IOThrowsError LispVal) 
Port Handle 

Instances

Show LispVal #

Make LispVal a member of the class Show

Methods

showsPrec :: Int -> LispVal -> ShowS

show :: LispVal -> String

showList :: [LispVal] -> ShowS

parseString :: Parser LispVal #

Function for string parsing

parseAtom :: Parser LispVal #

Function for parsing an atom, which is is a letter or symbol, followed by any number of letters, digits, or symbols.

parseNumber :: Parser LispVal #

Function for parsing a number

parseList :: Parser LispVal #

Function for parsing a list

parseDottedList :: Parser LispVal #

Function for parsing a dotted list

parseQuoted :: Parser LispVal #

Function for parsing a single-quoted value

parseExpr :: Parser LispVal #

Function for parsing an expression, which can be am atom, string, number, quoted, list, or dotted list.

type Env = IORef [(String, IORef LispVal)] #

Define a type for the environment

nullEnv :: IO Env #

An empty environment

type IOThrowsError = ExceptT LispError IO #

Error handling functionality on top of IO monad

runIOThrows :: IOThrowsError String -> IO String #

Catch errors

isBound :: Env -> String -> IO Bool #

Determine if a variable is already bound in the environment

getVar :: Env -> String -> IOThrowsError LispVal #

Retrieve current value of a variable

setVar :: Env -> String -> LispVal -> IOThrowsError LispVal #

Set variable value

defineVar :: Env -> String -> LispVal -> IOThrowsError LispVal #

Define a new variable, regardless of if it is already bound

data LispError #

Define datatype to represent an error

Constructors

NumArgs Integer [LispVal] 
TypeMismatch String LispVal 
Parser ParseError 
BadSpecialForm String LispVal 
NotFunction String String 
UnboundVar String String 
Default String 

Instances

Show LispError # 

Methods

showsPrec :: Int -> LispError -> ShowS

show :: LispError -> String

showList :: [LispError] -> ShowS

showError :: LispError -> String #

Make an instance of Show, and define how to print out error types

type ThrowsError = Either LispError #

Type to represent functions that may throw an error or return a value

trapError :: (Show a, MonadError a m) => m String -> m String #

Helper function to convert error to string representation

extractValue :: ThrowsError a -> a #

Extract error value

readOrThrow :: Parser a -> String -> ThrowsError a #

makeFunc :: Monad m => Maybe String -> Env -> [LispVal] -> [LispVal] -> m LispVal #

Helper function to create a function

makeNormalFunc :: Env -> [LispVal] -> [LispVal] -> ExceptT LispError IO LispVal #

Specialization of makeFunc for a normal function

makeVarArgs :: LispVal -> Env -> [LispVal] -> [LispVal] -> ExceptT LispError IO LispVal #

Specialization of makeFunc for a variable argument

load :: String -> IOThrowsError [LispVal] #

Read and parse a file full of statements

apply :: LispVal -> [LispVal] -> IOThrowsError LispVal #

Map eval function over the arguments

Define apply function

bindVars :: Env -> [(String, LispVal)] -> IO Env #

eval :: Env -> LispVal -> IOThrowsError LispVal #

Create the evaluator. This maps a code datatype to a 'data' datatype.

showVal :: LispVal -> String #

Function to specify how to display possible LispVals

unwordsList :: [LispVal] -> String #

Helper function to glue a list of words together with spaces