Safe Haskell | None |
---|
Provides a more specific type for arrays in Javascript (together with basic operations on them).
- data JSArray a
- array :: (SunroofValue a, Sunroof (ValueOf a)) => [a] -> JS t (JSArray (ValueOf a))
- newArray :: (SunroofArgument args, Sunroof a) => args -> JS t (JSArray a)
- length' :: JSSelector JSNumber
- lookup' :: Sunroof a => JSNumber -> JSArray a -> a
- insert' :: Sunroof a => JSNumber -> a -> JSArray a -> JS t ()
- push :: (SunroofArgument a, Sunroof a) => a -> JSArray a -> JS t ()
- pop :: Sunroof a => JSArray a -> JS t a
- shift :: Sunroof a => JSArray a -> JS t a
- unshift :: (SunroofArgument a, Sunroof a) => a -> JSArray a -> JS t ()
- forEach :: (Sunroof a, SunroofArgument a) => (a -> JS A ()) -> JSArray a -> JS t ()
- empty :: Sunroof a => JS t (JSArray a)
Documentation
Type if arrays in Javascript. The type parameter given the entry type.
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.
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.