sunroof-compiler-0.2: Monadic Javascript Compiler

Safe HaskellNone

Language.Sunroof.Selector

Description

JSSelector are used to access fields of Javascript objects.

Synopsis

Documentation

data JSSelector a Source

A JSSelector selects a field or attribute from a Javascript object. The phantom type is the type of the selected value. Note the selected field or attributes may also array entries (index).

Instances

Show (JSSelector a) 
IsString (JSSelector a)

Selectors can be created from the name of their attribute.

label :: JSString -> JSSelector aSource

Create a selector for a named field or attribute. For type safty it is adivsed to use this with an accompanying type signature. Example:

 array ! label "length"

See ! for further information on usage.

index :: JSNumber -> JSSelector aSource

Create a selector for an indexed value (e.g. array access). For type safty it is adivsed to use this with an accompanying type signature. Example:

 array ! index 4

See ! for further information on usage.

unboxSelector :: JSSelector a -> ExprSource

Provided for internal usage by the compiler. Unwraps the selector.

(!) :: forall o a. (Sunroof o, Sunroof a) => o -> JSSelector a -> aSource

Operator to use a selector on a Javascript object. Examples:

 array ! label "length"
 array ! index 4