Next: , Up: Developer manual   [Contents][Index]


2.1 Types module

Env

Env is a mutable (through IORef) list of maps, that ensures lexical scoping, the head of the list is the inner-most environment where symbols reside. If the symbol→value mapping is not found in that environment, it’s parents get searched.

ScmValue

This type contains all available values within the scheme interpreter. ScmRational, ScmReal, ScmComplex are currently not implemented, but they should be really easy to plug in.

This type provides facilities to wrap native haskell functions with a little bit of customisation. It also provides a generic value→string conversion capability.

ScmBoolean
ScmInteger
ScmRational
ScmReal
ScmComplex
ScmCharacter
ScmString

are pretty self explanatory

ScmSymbol

is internally the same as ScmString but it is upon evaluation used as a key for looking up symbol’s value in the current environment.

ScmList

This provides the standard Scheme list, with an exception. (see the entry bellow about ScmPair)

ScmPair

Contrary to Haskell, Scheme specification allows improper lists. Normal scheme list is (a . (b . (c . ()))) but improper list (a . (b . c)) where a, b, c are of any value.

To support those improper lists, hscheme supplies the ScmPair value type to facilitate those needs.

ScmVector

The difference between ScmVector and ScmList is that ScmVector is similar to arrays in imperative languages. As it has O(1) access times, ScmList has O(n).

ScmReturn

This type provide a monad capable of transfering state, IO actions, throw and catch exceptions and return values. It accepts one argument that is the payload value, that the monad wraps around. Most functions defined on Except, State, IO monads work as expected even here, if one is to use an IO action, simply wrap it with liftIO.

Other utility functions

These mostly provide a clean way to wrap functions in Haskell into the runtime. Keep in mind that if you want to make a list of ScmValue you cannot simply convert it to a list of Integer’s or similar, as that would break the strict Haskell type system. There is an implementation for ScmConvertible so you can convert [Integer] to [ScmValue], but if you want to do it the other way arround, you need to take care that that list is consting only of ScmInteger otherwise it is a hard crash.


Next: , Up: Developer manual   [Contents][Index]