haste-compiler-0.5.5.0: Haskell To ECMAScript compiler

Safe HaskellNone
LanguageHaskell98

Haste.Object

Description

Dealing with JavaScript objects on a low, low level.

Synopsis

Documentation

type JSObj = Maybe JSAny

A JS object: either null/undefined or Just an actual value.

data Type

Possible types of JS objects.

(#) :: JSLookup a => a -> JSString -> IO JSObj infixl 4

Look up a property on an object-like value.

asString :: JSObj -> IO (Maybe JSString)

Convert the object to a JSString.

asBool :: JSObj -> IO (Maybe Bool)

Convert the object to a Bool.

asNumber :: JSObj -> IO (Maybe Double)

Convert the object to a Double.

typeOf :: JSObj -> IO Type

Get the type of a JS object.

lookupPath :: JSObj -> [JSString] -> IO JSObj

Lookup a whole path at once. More efficient for long paths. x lookupPath ["a", "b"] is equivalent to x.a.b.

toObject :: [(JSString, JSAny)] -> JSAny

Build a new JS object from a list of key:value pairs.