module Haste (
JSString, JSAny, URL,
alert, prompt, eval, writeLog, catJSStr, fromJSStr,
onHashChange, onHashChange', setHash, getHash, setHash', getHash',
Random (..), Seed, next, mkSeed, newSeed,
Timer, Interval (..), setTimer, stopTimer,
JSType (..), JSNum (..), toString, fromString, convert
) where
import Haste.Prim
import Haste.Timer
import Haste.Random
import Haste.Prim.JSType
import Haste.Hash
import Haste.Foreign
import Control.Monad.IO.Class
jsAlert :: String -> IO ()
jsAlert = ffi "alert"
jsLog :: String -> IO ()
jsLog = ffi "(function(x){console.log(x);})"
jsPrompt :: String -> IO String
jsPrompt = ffi "(function(s){var x = prompt(s);\
\return (x === null) ? '' : x.toString();})"
jsEval :: JSString -> IO JSString
jsEval = ffi "(function(s){var x = eval(s);\
\return (typeof x === 'undefined') ? 'undefined' : x.toString();})"
alert :: MonadIO m => String -> m ()
alert = liftIO . jsAlert
prompt :: MonadIO m => String -> m String
prompt = liftIO . jsPrompt
eval :: MonadIO m => JSString -> m JSString
eval = liftIO . jsEval
writeLog :: MonadIO m => String -> m ()
writeLog = liftIO . jsLog