{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleInstances #-}
#ifdef ghcjs_HOST_OS
{-# LANGUAGE ForeignFunctionInterface, JavaScriptFFI #-}
{-# OPTIONS_GHC -Wno-dodgy-exports -Wno-dodgy-imports #-}
#endif
module Language.Javascript.JSaddle.Evaluate (
eval
) where
import Language.Javascript.JSaddle.Types (JSVal)
#ifdef ghcjs_HOST_OS
import Control.Monad.IO.Class (MonadIO(..))
import Language.Javascript.JSaddle.Types (JSString)
#else
import Language.Javascript.JSaddle.Native.Internal
(evaluateScript)
#endif
import Language.Javascript.JSaddle.Marshal.String (ToJSString(..))
import Language.Javascript.JSaddle.Monad (JSM)
eval :: (ToJSString script)
=> script
-> JSM JSVal
#ifdef ghcjs_HOST_OS
eval script = liftIO $ js_eval (toJSString script)
foreign import javascript safe
#if __GLASGOW_HASKELL__ >= 900
"(($1) => { return eval($1); })"
#else
"$r = eval($1);"
#endif
js_eval :: JSString -> IO JSVal
#else
eval :: forall script. ToJSString script => script -> JSM JSVal
eval = JSString -> JSM JSVal
evaluateScript (JSString -> JSM JSVal)
-> (script -> JSString) -> script -> JSM JSVal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. script -> JSString
forall a. ToJSString a => a -> JSString
toJSString
#endif