Safe Haskell | None |
---|---|
Language | Haskell98 |
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.
- data JSString
- data JSAny
- type URL = String
- alert :: MonadIO m => String -> m ()
- prompt :: MonadIO m => String -> m String
- eval :: MonadIO m => JSString -> m JSString
- writeLog :: MonadIO m => String -> m ()
- catJSStr :: JSString -> [JSString] -> JSString
- fromJSStr :: JSString -> String
- class JSType a where
- toJSString :: a -> JSString
- fromJSString :: JSString -> Maybe a
- class JSNum a where
- toNumber :: a -> Double
- fromNumber :: Double -> a
- toString :: JSType a => a -> String
- fromString :: JSType a => String -> Maybe a
- convert :: (JSNum a, JSNum b) => a -> b
- newtype Elem = Elem JSAny
- class IsElem a where
- data Attribute
- data AttrName
- set :: (IsElem e, MonadIO m) => e -> [Attribute] -> m ()
- with :: (IsElem e, MonadIO m) => m e -> [Attribute] -> m e
- attribute :: AttrName -> JSString -> Attribute
- children :: [Elem] -> Attribute
- click :: (IsElem e, MonadIO m) => e -> m ()
- focus :: (IsElem e, MonadIO m) => e -> m ()
- blur :: (IsElem e, MonadIO m) => e -> m ()
- document :: Elem
- documentBody :: Elem
- deleteChild :: (IsElem parent, IsElem child, MonadIO m) => parent -> child -> m ()
- clearChildren :: (IsElem e, MonadIO m) => e -> m ()
- setChildren :: (IsElem parent, IsElem child, MonadIO m) => parent -> [child] -> m ()
- getChildren :: (IsElem e, MonadIO m) => e -> m [Elem]
- getLastChild :: (IsElem e, MonadIO m) => e -> m (Maybe Elem)
- getFirstChild :: (IsElem e, MonadIO m) => e -> m (Maybe Elem)
- getChildBefore :: (IsElem e, MonadIO m) => e -> m (Maybe Elem)
- insertChildBefore :: (IsElem parent, IsElem before, IsElem child, MonadIO m) => parent -> before -> child -> m ()
- appendChild :: (IsElem parent, IsElem child, MonadIO m) => parent -> child -> m ()
- removeChild :: (IsElem parent, IsElem child, MonadIO m) => child -> parent -> m ()
- addChild :: (IsElem parent, IsElem child, MonadIO m) => child -> parent -> m ()
- addChildBefore :: (IsElem parent, IsElem child, MonadIO m) => child -> parent -> child -> m ()
- data Timer
- data Interval
- setTimer :: MonadEvent m => Interval -> m () -> m Timer
- stopTimer :: MonadIO m => Timer -> m ()
- class Random a where
- data Seed
- next :: Seed -> Seed
- mkSeed :: Int -> Seed
- newSeed :: MonadIO m => m Seed
- onHashChange :: MonadIO m => (String -> String -> IO ()) -> m ()
- onHashChange' :: MonadIO m => (JSString -> JSString -> IO ()) -> m ()
- setHash :: MonadIO m => String -> m ()
- getHash :: MonadIO m => m String
- setHash' :: MonadIO m => JSString -> m ()
- getHash' :: MonadIO m => m JSString
Documentation
JSStrings are represented as normal strings server-side; should probably be changed to ByteString or Text.
catJSStr :: JSString -> [JSString] -> JSString Source
Concatenate a series of JSStrings using the specified separator.
Any type which can be converted to/from a JSString
.
toJSString :: a -> JSString Source
fromJSString :: JSString -> Maybe a Source
(Almost) all numeric types can be efficiently converted to and from Double, which is the internal representation for most of them.
fromString :: JSType a => String -> Maybe a Source
The class of types backed by DOM elements.
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.
The name of an attribute. May be either a common property, an HTML attribute or a style attribute.
set :: (IsElem e, MonadIO m) => e -> [Attribute] -> m () Source
Set a number of Attribute
s on an element.
with :: (IsElem e, MonadIO m) => m e -> [Attribute] -> m e Source
Set a number of Attribute
s on the element produced by an IO action.
Gives more convenient syntax when creating elements:
newElem "div" `with` [ style "border" =: "1px solid black", ... ]
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. Note that deleteChild = flip removeChild.
DEPRECATED: use deleteChild
instead!
Note that deleteChild = flip removeChild
.
addChild :: (IsElem parent, IsElem child, MonadIO m) => child -> parent -> m () Source
Deprecated: Use appendChild instead. Note that appendChild == flip addChild.
DEPRECATED: use appendChild
instead!
Note that appendChild == flip addChild
.
addChildBefore :: (IsElem parent, IsElem child, MonadIO m) => child -> parent -> child -> m () Source
Deprecated: Use insertChildBefore instead. Note insertChildBefore == parent new old -> addChildBefore new parent old.
DEPRECATED: use insertChildBefore
instead!
Note that
insertChildBefore == parent new old -> addChildBefore new parent old
.
Interval and repeat for timers.
:: 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.
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
.