haste-compiler-0.5.1.1: Haskell To ECMAScript compiler

Safe HaskellNone
LanguageHaskell98

Haste

Description

Haste's companion to the Prelude.

Note that this module should *not* be imported together with Haste.App, which provides the same functionality but slightly modified for automatic program slicing.

Synopsis

Documentation

data JSString Source

JSStrings are represented as normal strings server-side; should probably be changed to ByteString or Text.

data JSAny Source

Any JS value, with one layer of indirection.

alert :: MonadIO m => String -> m () Source

Javascript alert() function.

prompt :: MonadIO m => String -> m String Source

Javascript prompt() function.

eval :: MonadIO m => JSString -> m JSString Source

Javascript eval() function.

writeLog :: MonadIO m => String -> m () Source

Use console.log to write a message.

catJSStr :: JSString -> [JSString] -> JSString Source

Concatenate a series of JSStrings using the specified separator.

class JSNum a where Source

(Almost) all numeric types can be efficiently converted to and from Double, which is the internal representation for most of them.

convert :: (JSNum a, JSNum b) => a -> b Source

newtype Elem Source

A DOM node.

Constructors

Elem JSAny 

class IsElem a where Source

The class of types backed by DOM elements.

Minimal complete definition

elemOf

Methods

elemOf :: a -> Elem Source

Get the element representing the object.

fromElem :: Elem -> IO (Maybe a) Source

Attempt to create an object from an Elem.

data Attribute Source

A key/value pair representing the value of an attribute. May represent a property, an HTML attribute, a style attribute or a list of child elements.

data AttrName Source

The name of an attribute. May be either a common property, an HTML attribute or a style attribute.

Instances

set :: (IsElem e, MonadIO m) => e -> [Attribute] -> m () Source

Set a number of Attributes on an element.

with :: (IsElem e, MonadIO m) => m e -> [Attribute] -> m e Source

Set a number of Attributes on the element produced by an IO action. Gives more convenient syntax when creating elements:

newElem "div" with [ style "border" =: "1px solid black", ... ]

children :: [Elem] -> Attribute Source

Attribute adding a list of child nodes to an element.

click :: (IsElem e, MonadIO m) => e -> m () Source

Generate a click event on an element.

focus :: (IsElem e, MonadIO m) => e -> m () Source

Generate a focus event on an element.

blur :: (IsElem e, MonadIO m) => e -> m () Source

Generate a blur event on an element.

document :: Elem Source

The DOM node corresponding to document.

documentBody :: Elem Source

The DOM node corresponding to document.body.

deleteChild :: (IsElem parent, IsElem child, MonadIO m) => parent -> child -> m () Source

Remove the second element from the first's children.

clearChildren :: (IsElem e, MonadIO m) => e -> m () Source

Remove all children from the given element.

setChildren :: (IsElem parent, IsElem child, MonadIO m) => parent -> [child] -> m () Source

Clear the given element's list of children, and append all given children to it.

getChildren :: (IsElem e, MonadIO m) => e -> m [Elem] Source

Get a list of all children belonging to a certain element.

getLastChild :: (IsElem e, MonadIO m) => e -> m (Maybe Elem) Source

Get the last of an element's children.

getFirstChild :: (IsElem e, MonadIO m) => e -> m (Maybe Elem) Source

Get the first of an element's children.

getChildBefore :: (IsElem e, MonadIO m) => e -> m (Maybe Elem) Source

Get the sibling before the given one, if any.

insertChildBefore :: (IsElem parent, IsElem before, IsElem child, MonadIO m) => parent -> before -> child -> m () Source

Insert an element into a container, before another element. For instance: insertChildBefore theContainer olderChild childToAdd

appendChild :: (IsElem parent, IsElem child, MonadIO m) => parent -> child -> m () Source

Append the first element as a child of the second element.

removeChild :: (IsElem parent, IsElem child, MonadIO m) => child -> parent -> m () Source

Deprecated: Use deleteChild instead

DEPRECATED: use deleteChild instead!

addChild :: (IsElem parent, IsElem child, MonadIO m) => child -> parent -> m () Source

Deprecated: Use appendChild instead

DEPRECATED: use appendChild instead!

addChildBefore :: (IsElem parent, IsElem child, MonadIO m) => child -> parent -> child -> m () Source

Deprecated: Use insertChildBefore instead

DEPRECATED: use insertChildBefore instead!

data Timer Source

Timer handle.

data Interval Source

Interval and repeat for timers.

Constructors

Once !Int

Fire once, in n milliseconds.

Repeat !Int

Fire every n milliseconds.

setTimer Source

Arguments

:: MonadEvent m 
=> Interval

Milliseconds until timer fires.

-> m ()

Function to call when timer fires.

-> m Timer

Timer handle for interacting with the timer.

Set a timer.

stopTimer :: MonadIO m => Timer -> m () Source

Stop a timer.

class Random a where Source

Minimal complete definition

randomR

Methods

randomR :: (a, a) -> Seed -> (a, Seed) Source

Generate a pseudo random number between a lower (inclusive) and higher (exclusive) bound.

randomRs :: (a, a) -> Seed -> [a] Source

next :: Seed -> Seed Source

Generate the next seed in the sequence.

mkSeed :: Int -> Seed Source

Create a new seed from an integer.

newSeed :: MonadIO m => m Seed Source

Generate a new seed using Javascript's PRNG.

onHashChange :: MonadIO m => (String -> String -> IO ()) -> m () Source

Register a callback to be run whenever the URL hash changes. The two arguments of the callback are the new and old hash respectively.

onHashChange' :: MonadIO m => (JSString -> JSString -> IO ()) -> m () Source

JSString version of onHashChange.

setHash :: MonadIO m => String -> m () Source

Set the hash part of the current URL.

getHash :: MonadIO m => m String Source

Read the hash part of the currunt URL.

setHash' :: MonadIO m => JSString -> m () Source

Set the hash part of the current URL - JSString version.

getHash' :: MonadIO m => m JSString Source

Read the hash part of the currunt URL - JSString version.