processing-1.2.0.1: Web graphic applications with processing.js.

Safe HaskellNone

Graphics.Web.Processing.Core.Var

Contents

Description

Module exporting Var and ArrayVar type and functions.

Synopsis

Variables

The variable system presented here is actually an artifact to make explicit which values may change over time and which don't. It also guides the user to create variables before use them and do so in a more natural way. Somehow, it tries to be similar to IORefs, while they aren't. Strictly speaking, they do not contain any value, but it will contain a value when processing.js executes the resulting code. To make sure you are doing the right thing, variables are typed, thus forcing you to feed the correct functions with the correct values.

data Var a Source

Type of variables.

data ArrayVar a Source

Type of variables storing arrays.

arraySize :: ArrayVar a -> IntSource

Size of the array.

Functions

varName :: Var a -> TextSource

Get the name of a variable.

arrayVarName :: ArrayVar a -> TextSource

Get the name of a variable storing an array.

newVar :: (ProcMonad m, ProcType a) => a -> m Preamble (Var a)Source

Create a new variable with a starting value.

readVar :: (ProcMonad m, ProcType a) => Var a -> m c aSource

Read a variable.

writeVar :: (ProcMonad m, ProcType a) => Var a -> a -> m c ()Source

Write a new value to a variable.

newArrayVar :: (ProcMonad m, ProcType a) => [a] -> m Preamble (ArrayVar a)Source

Create a new array variable with a starting list of values.

readArrayVar :: (ProcMonad m, Monad (m c), ProcType a) => ArrayVar a -> Proc_Int -> m c aSource

Read a component of an array variable.

writeArrayVar :: (ProcMonad m, ProcType a) => ArrayVar a -> Proc_Int -> a -> m c ()Source

Write a component of an array variable.