sunroof-compiler-0.2: Monadic Javascript Compiler

Safe HaskellNone

Language.Sunroof.JS.Array

Description

Provides a more specific type for arrays in Javascript (together with basic operations on them).

Synopsis

Documentation

data JSArray a Source

Type if arrays in Javascript. The type parameter given the entry type.

Instances

Show (JSArray a)

Show the Javascript.

Sunroof a => IfB (JSArray a)

You can write branches that return arrays.

Sunroof a => Sunroof (JSArray a)

Arrays are first-class Javascript values.

array :: (SunroofValue a, Sunroof (ValueOf a)) => [a] -> JS t (JSArray (ValueOf a))Source

Create a literal array from a Haskell list.

newArray :: (SunroofArgument args, Sunroof a) => args -> JS t (JSArray a)Source

Create a new array object containing the given values.

length' :: JSSelector JSNumberSource

The length property of arrays.

lookup' :: Sunroof a => JSNumber -> JSArray a -> aSource

A type-safe version of array lookup.

insert' :: Sunroof a => JSNumber -> a -> JSArray a -> JS t ()Source

A type-safe version of array insert.

push :: (SunroofArgument a, Sunroof a) => a -> JSArray a -> JS t ()Source

Push a element into the array as if it was a stack. Returns nothing instead of the new length. See http://www.w3schools.com/jsref/jsref_push.asp.

pop :: Sunroof a => JSArray a -> JS t aSource

Pop a element from the array as if it was a stack. See http://www.w3schools.com/jsref/jsref_pop.asp.

shift :: Sunroof a => JSArray a -> JS t aSource

Removes and return the first element of an array (dequeue). See http://www.w3schools.com/jsref/jsref_shift.asp.

unshift :: (SunroofArgument a, Sunroof a) => a -> JSArray a -> JS t ()Source

Adds a new element to the beginning of the array (queue). Returns nothing instead of the new length. See http://www.w3schools.com/jsref/jsref_unshift.asp.

forEach :: (Sunroof a, SunroofArgument a) => (a -> JS A ()) -> JSArray a -> JS t ()Source

Foreach iteration method provided by most browsers. Execute the given action on each element of the array. See https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/forEach, http://msdn.microsoft.com/en-us/library/ie/ff679980.aspx.

empty :: Sunroof a => JS t (JSArray a)Source

The empty array.