Portability | portable |
---|---|
Stability | experimental |
Maintainer | github.com/justinethier |
Safe Haskell | None |
This module contains code for working with Scheme variables, and the environments that contain them.
- printEnv :: Env -> IO String
- recPrintEnv :: Env -> IO String
- recExportsFromEnv :: Env -> IO [LispVal]
- exportsFromEnv :: Env -> IO [LispVal]
- copyEnv :: Env -> IO Env
- extendEnv :: Env -> [((Char, String), LispVal)] -> IO Env
- importEnv :: Env -> Env -> IO Env
- topmostEnv :: Env -> IO Env
- nullEnvWithParent :: Env -> IO Env
- findNamespacedEnv :: Env -> Char -> String -> IO (Maybe Env)
- macroNamespace :: Char
- varNamespace :: Char
- getVar :: Env -> String -> IOThrowsError LispVal
- getVar' :: Env -> String -> IOThrowsError (Maybe LispVal)
- getNamespacedVar :: Env -> Char -> String -> IOThrowsError LispVal
- getNamespacedVar' :: Env -> Char -> String -> IOThrowsError (Maybe LispVal)
- getNamespacedRef :: Env -> Char -> String -> IOThrowsError (IORef LispVal)
- defineVar :: Env -> String -> LispVal -> IOThrowsError LispVal
- defineNamespacedVar :: Env -> Char -> String -> LispVal -> IOThrowsError LispVal
- setVar :: Env -> String -> LispVal -> IOThrowsError LispVal
- setNamespacedVar :: Env -> Char -> String -> LispVal -> IOThrowsError LispVal
- updateObject :: Env -> String -> LispVal -> IOThrowsError LispVal
- updateNamespacedObject :: Env -> Char -> String -> LispVal -> IOThrowsError LispVal
- isBound :: Env -> String -> IO Bool
- isRecBound :: Env -> String -> IO Bool
- isNamespacedRecBound :: Env -> Char -> String -> IO Bool
- derefPtr :: LispVal -> IOThrowsError LispVal
- recDerefPtrs :: LispVal -> IOThrowsError LispVal
- safeRecDerefPtrs :: [LispVal] -> LispVal -> IOThrowsError LispVal
- recDerefToFnc :: ([LispVal] -> ThrowsError LispVal) -> [LispVal] -> IOThrowsError LispVal
Environments
:: Env | Environment |
-> IO String | Contents of the env as a string |
Show the contents of an environment
recPrintEnv :: Env -> IO String
Recursively print an environment to string
recExportsFromEnv :: Env -> IO [LispVal]
Recursively find all exports from the given environment
exportsFromEnv :: Env -> IO [LispVal]
Return a list of symbols exported from an environment
Create a deep copy of an environment
:: Env | Environment |
-> [((Char, String), LispVal)] | Extensions to the environment |
-> IO Env | Extended environment |
Extend given environment by binding a series of values to a new environment.
Perform a deep copy of an environment's contents into another environment.
The destination environment is modified!
topmostEnv :: Env -> IO Env
Find the top-most environment
nullEnvWithParent :: Env -> IO Env
Create a null environment with the given environment as its parent.
:: Env | Environment to begin the search; parent env's will be searched as well. |
-> Char | Namespace |
-> String | Variable |
-> IO (Maybe Env) | Environment, or Nothing if there was no match. |
Recursively search environments to find one that contains the given variable.
macroNamespace :: Char
Internal namespace for macros
varNamespace :: Char
Internal namespace for variables
Getters
:: Env | Environment |
-> String | Variable |
-> IOThrowsError LispVal | Contents of the variable |
Retrieve the value of a variable defined in the default namespace
:: Env | Environment |
-> String | Variable |
-> IOThrowsError (Maybe LispVal) | Contents of the variable |
Retrieve the value of a variable defined in the default namespace, or Nothing if it is not defined
:: Env | Environment |
-> Char | Namespace |
-> String | Variable |
-> IOThrowsError LispVal | Contents of the variable |
Retrieve the value of a variable defined in a given namespace
:: Env | Environment |
-> Char | Namespace |
-> String | Variable |
-> IOThrowsError (Maybe LispVal) | Contents of the variable, if found |
Retrieve the value of a variable defined in a given namespace, or Nothing if it is not defined
:: Env | Environment |
-> Char | Namespace |
-> String | Variable |
-> IOThrowsError (IORef LispVal) |
Retrieve an ioRef defined in a given namespace
Setters
:: Env | Environment |
-> String | Variable |
-> LispVal | Value |
-> IOThrowsError LispVal | Value |
Bind a variable in the default namespace
:: Env | Environment |
-> Char | Namespace |
-> String | Variable |
-> LispVal | Value |
-> IOThrowsError LispVal | Value |
Bind a variable in the given namespace
:: Env | Environment |
-> String | Variable |
-> LispVal | Value |
-> IOThrowsError LispVal | Value |
Set a variable in the default namespace
:: Env | Environment |
-> Char | Namespace |
-> String | Variable |
-> LispVal | Value |
-> IOThrowsError LispVal | Value |
Set a variable in a given namespace
updateObject :: Env -> String -> LispVal -> IOThrowsError LispVal
A wrapper for updateNamespaceObject that uses the variable namespace.
:: Env | Environment |
-> Char | Namespace |
-> String | Variable |
-> LispVal | Value |
-> IOThrowsError LispVal | Value |
This function updates the object that the variable refers to. If it is a pointer, that means this function will update that pointer (or the last pointer in the chain) to point to the given value object. If the variable is not a pointer, the result is the same as a setVar (but without updating any pointer references, see below).
Note this function only updates the object, it does not update any associated pointers. So it should probably only be used internally by husk, unless you really know what you are doing!
Predicates
:: Env | Environment |
-> String | Variable |
-> IO Bool | True if the variable is bound |
Determine if a variable is bound in the default namespace
:: Env | Environment |
-> String | Variable |
-> IO Bool | True if the variable is bound |
Determine if a variable is bound in the default namespace, in this environment or one of its parents.
:: Env | Environment |
-> Char | Namespace |
-> String | Variable |
-> IO Bool | True if the variable is bound |
Determine if a variable is bound in a given namespace or a parent of the given environment.
Pointers
derefPtr :: LispVal -> IOThrowsError LispVal
Return a value with a pointer dereferenced, if necessary
recDerefPtrs :: LispVal -> IOThrowsError LispVal
Recursively process the given data structure, dereferencing any pointers found along the way.
This could potentially be expensive on large data structures since it must walk the entire object.
safeRecDerefPtrs :: [LispVal] -> LispVal -> IOThrowsError LispVal
Attempt to dereference pointers safely, without being caught in a cycle
recDerefToFnc :: ([LispVal] -> ThrowsError LispVal) -> [LispVal] -> IOThrowsError LispVal
A helper to recursively dereference all pointers and pass results to a function