{-# LANGUAGE CPP #-}
#ifdef ghcjs_HOST_OS
{-# OPTIONS_GHC -Wno-dodgy-exports #-}
#else
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE ImplicitParams #-}
#endif
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE TypeOperators #-}
module Language.Javascript.JSaddle.Types (
JSContextRef(..)
, JSM(..)
, MonadJSM(..)
, liftJSM
, GHCJSPure(..)
, ghcjsPure
, ghcjsPureMap
, ghcjsPureId
, JSVal(..)
, IsJSVal(..)
, jsval
, SomeJSArray(..)
, JSArray
, MutableJSArray
, STJSArray
, Object(..)
, JSString(..)
, Nullable(..)
, JSCallAsFunction
, JSadddleHasCallStack
, syncPoint
, syncAfter
#ifndef ghcjs_HOST_OS
, sendCommand
, MutabilityType(..)
, Mutable
, Immutable
, IsItMutable(..)
, Mutability
, JSValueReceived(..)
, JSValueForSend(..)
, JSStringReceived(..)
, JSStringForSend(..)
, JSObjectForSend(..)
, AsyncCommand(..)
, Command(..)
, Batch(..)
, Result(..)
, BatchResults(..)
, Results(..)
#endif
) where
import Control.Monad.IO.Class (MonadIO(..))
#ifdef ghcjs_HOST_OS
import GHCJS.Types
import JavaScript.Object.Internal (Object(..))
import JavaScript.Array.Internal (SomeJSArray(..), JSArray, MutableJSArray, STJSArray)
import GHCJS.Nullable (Nullable(..))
#else
import GHCJS.Prim.Internal (JSVal(..), JSValueRef)
import Data.JSString.Internal.Type (JSString(..))
import Control.DeepSeq (NFData(..))
import Control.Monad.Catch (MonadThrow, MonadCatch(..), MonadMask(..))
import Control.Monad.Trans.Cont (ContT(..))
import Control.Monad.Trans.Except (ExceptT(..))
import Control.Monad.Trans.Identity (IdentityT(..))
import Control.Monad.Trans.Maybe (MaybeT(..))
import Control.Monad.Trans.Reader (ReaderT(..), ask)
import Control.Monad.Trans.RWS.Lazy as Lazy (RWST(..))
import Control.Monad.Trans.RWS.Strict as Strict (RWST(..))
import Control.Monad.Trans.State.Lazy as Lazy (StateT(..))
import Control.Monad.Trans.State.Strict as Strict (StateT(..))
import Control.Monad.Trans.Writer.Lazy as Lazy (WriterT(..))
import Control.Monad.Trans.Writer.Strict as Strict (WriterT(..))
import Control.Monad.Trans.Class (MonadTrans(..))
import Control.Monad.Fix (MonadFix)
import Control.Monad.Ref (MonadAtomicRef(..), MonadRef(..))
import Control.Concurrent.STM.TVar (TVar)
import Control.Concurrent.MVar (MVar)
import Data.Int (Int64)
import Data.Set (Set)
import Data.Text (Text)
import Data.Time.Clock (UTCTime(..))
import Data.Typeable (Typeable)
import Data.Coerce (coerce, Coercible)
import Data.Aeson
(defaultOptions, genericToEncoding, ToJSON(..), FromJSON(..), Value)
import GHC.Generics (Generic)
import Control.Monad.IO.Unlift (MonadUnliftIO)
import qualified Control.Monad.Fail as Fail
#endif
#if MIN_VERSION_base(4,9,0) && defined(CHECK_UNCHECKED)
import GHC.Stack (HasCallStack)
#else
import GHC.Exts (Constraint)
#endif
#ifdef ghcjs_HOST_OS
type JSContextRef = ()
#else
data JSContextRef = JSContextRef {
JSContextRef -> Int64
contextId :: Int64
, JSContextRef -> UTCTime
startTime :: UTCTime
, JSContextRef -> Command -> IO Result
doSendCommand :: Command -> IO Result
, JSContextRef -> AsyncCommand -> IO ()
doSendAsyncCommand :: AsyncCommand -> IO ()
, JSContextRef -> Object -> JSCallAsFunction -> IO ()
addCallback :: Object -> JSCallAsFunction -> IO ()
, JSContextRef -> TVar Int64
nextRef :: TVar JSValueRef
, JSContextRef -> Bool -> IO ()
doEnableLogging :: Bool -> IO ()
, JSContextRef -> MVar (Set Text)
finalizerThreads :: MVar (Set Text)
, JSContextRef -> MVar [Double -> JSM ()]
animationFrameHandlers :: MVar [Double -> JSM ()]
, JSContextRef -> MVar (Set Int64)
liveRefs :: MVar (Set Int64)
}
#endif
#ifdef ghcjs_HOST_OS
type JSM = IO
#else
newtype JSM a = JSM { forall a. JSM a -> ReaderT JSContextRef IO a
unJSM :: ReaderT JSContextRef IO a }
deriving ((forall a b. (a -> b) -> JSM a -> JSM b)
-> (forall a b. a -> JSM b -> JSM a) -> Functor JSM
forall a b. a -> JSM b -> JSM a
forall a b. (a -> b) -> JSM a -> JSM b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall a b. (a -> b) -> JSM a -> JSM b
fmap :: forall a b. (a -> b) -> JSM a -> JSM b
$c<$ :: forall a b. a -> JSM b -> JSM a
<$ :: forall a b. a -> JSM b -> JSM a
Functor, Functor JSM
Functor JSM =>
(forall a. a -> JSM a)
-> (forall a b. JSM (a -> b) -> JSM a -> JSM b)
-> (forall a b c. (a -> b -> c) -> JSM a -> JSM b -> JSM c)
-> (forall a b. JSM a -> JSM b -> JSM b)
-> (forall a b. JSM a -> JSM b -> JSM a)
-> Applicative JSM
forall a. a -> JSM a
forall a b. JSM a -> JSM b -> JSM a
forall a b. JSM a -> JSM b -> JSM b
forall a b. JSM (a -> b) -> JSM a -> JSM b
forall a b c. (a -> b -> c) -> JSM a -> JSM b -> JSM c
forall (f :: * -> *).
Functor f =>
(forall a. a -> f a)
-> (forall a b. f (a -> b) -> f a -> f b)
-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
-> (forall a b. f a -> f b -> f b)
-> (forall a b. f a -> f b -> f a)
-> Applicative f
$cpure :: forall a. a -> JSM a
pure :: forall a. a -> JSM a
$c<*> :: forall a b. JSM (a -> b) -> JSM a -> JSM b
<*> :: forall a b. JSM (a -> b) -> JSM a -> JSM b
$cliftA2 :: forall a b c. (a -> b -> c) -> JSM a -> JSM b -> JSM c
liftA2 :: forall a b c. (a -> b -> c) -> JSM a -> JSM b -> JSM c
$c*> :: forall a b. JSM a -> JSM b -> JSM b
*> :: forall a b. JSM a -> JSM b -> JSM b
$c<* :: forall a b. JSM a -> JSM b -> JSM a
<* :: forall a b. JSM a -> JSM b -> JSM a
Applicative, Applicative JSM
Applicative JSM =>
(forall a b. JSM a -> (a -> JSM b) -> JSM b)
-> (forall a b. JSM a -> JSM b -> JSM b)
-> (forall a. a -> JSM a)
-> Monad JSM
forall a. a -> JSM a
forall a b. JSM a -> JSM b -> JSM b
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *).
Applicative m =>
(forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> Monad m
$c>>= :: forall a b. JSM a -> (a -> JSM b) -> JSM b
>>= :: forall a b. JSM a -> (a -> JSM b) -> JSM b
$c>> :: forall a b. JSM a -> JSM b -> JSM b
>> :: forall a b. JSM a -> JSM b -> JSM b
$creturn :: forall a. a -> JSM a
return :: forall a. a -> JSM a
Monad, Monad JSM
Monad JSM => (forall a. IO a -> JSM a) -> MonadIO JSM
forall a. IO a -> JSM a
forall (m :: * -> *).
Monad m =>
(forall a. IO a -> m a) -> MonadIO m
$cliftIO :: forall a. IO a -> JSM a
liftIO :: forall a. IO a -> JSM a
MonadIO, Monad JSM
Monad JSM => (forall a. (a -> JSM a) -> JSM a) -> MonadFix JSM
forall a. (a -> JSM a) -> JSM a
forall (m :: * -> *).
Monad m =>
(forall a. (a -> m a) -> m a) -> MonadFix m
$cmfix :: forall a. (a -> JSM a) -> JSM a
mfix :: forall a. (a -> JSM a) -> JSM a
MonadFix, Monad JSM
Monad JSM =>
(forall e a. (HasCallStack, Exception e) => e -> JSM a)
-> MonadThrow JSM
forall e a. (HasCallStack, Exception e) => e -> JSM a
forall (m :: * -> *).
Monad m =>
(forall e a. (HasCallStack, Exception e) => e -> m a)
-> MonadThrow m
$cthrowM :: forall e a. (HasCallStack, Exception e) => e -> JSM a
throwM :: forall e a. (HasCallStack, Exception e) => e -> JSM a
MonadThrow, MonadIO JSM
MonadIO JSM =>
(forall b. ((forall a. JSM a -> IO a) -> IO b) -> JSM b)
-> MonadUnliftIO JSM
forall b. ((forall a. JSM a -> IO a) -> IO b) -> JSM b
forall (m :: * -> *).
MonadIO m =>
(forall b. ((forall a. m a -> IO a) -> IO b) -> m b)
-> MonadUnliftIO m
$cwithRunInIO :: forall b. ((forall a. JSM a -> IO a) -> IO b) -> JSM b
withRunInIO :: forall b. ((forall a. JSM a -> IO a) -> IO b) -> JSM b
MonadUnliftIO, Monad JSM
Monad JSM => (forall a. String -> JSM a) -> MonadFail JSM
forall a. String -> JSM a
forall (m :: * -> *).
Monad m =>
(forall a. String -> m a) -> MonadFail m
$cfail :: forall a. String -> JSM a
fail :: forall a. String -> JSM a
Fail.MonadFail)
instance MonadCatch JSM where
JSM a
t catch :: forall e a.
(HasCallStack, Exception e) =>
JSM a -> (e -> JSM a) -> JSM a
`catch` e -> JSM a
c = ReaderT JSContextRef IO a -> JSM a
forall a. ReaderT JSContextRef IO a -> JSM a
JSM (JSM a -> ReaderT JSContextRef IO a
forall a. JSM a -> ReaderT JSContextRef IO a
unJSM (JSM a -> JSM a
forall a. JSM a -> JSM a
syncAfter JSM a
t) ReaderT JSContextRef IO a
-> (e -> ReaderT JSContextRef IO a) -> ReaderT JSContextRef IO a
forall e a.
(HasCallStack, Exception e) =>
ReaderT JSContextRef IO a
-> (e -> ReaderT JSContextRef IO a) -> ReaderT JSContextRef IO a
forall (m :: * -> *) e a.
(MonadCatch m, HasCallStack, Exception e) =>
m a -> (e -> m a) -> m a
`catch` \e
e -> JSM a -> ReaderT JSContextRef IO a
forall a. JSM a -> ReaderT JSContextRef IO a
unJSM (e -> JSM a
c e
e))
instance MonadMask JSM where
mask :: forall b.
HasCallStack =>
((forall a. JSM a -> JSM a) -> JSM b) -> JSM b
mask (forall a. JSM a -> JSM a) -> JSM b
a = ReaderT JSContextRef IO b -> JSM b
forall a. ReaderT JSContextRef IO a -> JSM a
JSM (ReaderT JSContextRef IO b -> JSM b)
-> ReaderT JSContextRef IO b -> JSM b
forall a b. (a -> b) -> a -> b
$ ((forall a. ReaderT JSContextRef IO a -> ReaderT JSContextRef IO a)
-> ReaderT JSContextRef IO b)
-> ReaderT JSContextRef IO b
forall b.
HasCallStack =>
((forall a. ReaderT JSContextRef IO a -> ReaderT JSContextRef IO a)
-> ReaderT JSContextRef IO b)
-> ReaderT JSContextRef IO b
forall (m :: * -> *) b.
(MonadMask m, HasCallStack) =>
((forall a. m a -> m a) -> m b) -> m b
mask (((forall a.
ReaderT JSContextRef IO a -> ReaderT JSContextRef IO a)
-> ReaderT JSContextRef IO b)
-> ReaderT JSContextRef IO b)
-> ((forall a.
ReaderT JSContextRef IO a -> ReaderT JSContextRef IO a)
-> ReaderT JSContextRef IO b)
-> ReaderT JSContextRef IO b
forall a b. (a -> b) -> a -> b
$ \forall a. ReaderT JSContextRef IO a -> ReaderT JSContextRef IO a
unmask -> JSM b -> ReaderT JSContextRef IO b
forall a. JSM a -> ReaderT JSContextRef IO a
unJSM ((forall a. JSM a -> JSM a) -> JSM b
a ((forall a. JSM a -> JSM a) -> JSM b)
-> (forall a. JSM a -> JSM a) -> JSM b
forall a b. (a -> b) -> a -> b
$ (ReaderT JSContextRef IO a -> ReaderT JSContextRef IO a)
-> JSM a -> JSM a
forall a.
(ReaderT JSContextRef IO a -> ReaderT JSContextRef IO a)
-> JSM a -> JSM a
q ReaderT JSContextRef IO a -> ReaderT JSContextRef IO a
forall a. ReaderT JSContextRef IO a -> ReaderT JSContextRef IO a
unmask)
where q :: (ReaderT JSContextRef IO a -> ReaderT JSContextRef IO a) -> JSM a -> JSM a
q :: forall a.
(ReaderT JSContextRef IO a -> ReaderT JSContextRef IO a)
-> JSM a -> JSM a
q ReaderT JSContextRef IO a -> ReaderT JSContextRef IO a
unmask (JSM ReaderT JSContextRef IO a
b) = JSM a -> JSM a
forall a. JSM a -> JSM a
syncAfter (JSM a -> JSM a)
-> (ReaderT JSContextRef IO a -> JSM a)
-> ReaderT JSContextRef IO a
-> JSM a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ReaderT JSContextRef IO a -> JSM a
forall a. ReaderT JSContextRef IO a -> JSM a
JSM (ReaderT JSContextRef IO a -> JSM a)
-> ReaderT JSContextRef IO a -> JSM a
forall a b. (a -> b) -> a -> b
$ ReaderT JSContextRef IO a -> ReaderT JSContextRef IO a
unmask ReaderT JSContextRef IO a
b
uninterruptibleMask :: forall b.
HasCallStack =>
((forall a. JSM a -> JSM a) -> JSM b) -> JSM b
uninterruptibleMask (forall a. JSM a -> JSM a) -> JSM b
a =
ReaderT JSContextRef IO b -> JSM b
forall a. ReaderT JSContextRef IO a -> JSM a
JSM (ReaderT JSContextRef IO b -> JSM b)
-> ReaderT JSContextRef IO b -> JSM b
forall a b. (a -> b) -> a -> b
$ ((forall a. ReaderT JSContextRef IO a -> ReaderT JSContextRef IO a)
-> ReaderT JSContextRef IO b)
-> ReaderT JSContextRef IO b
forall b.
HasCallStack =>
((forall a. ReaderT JSContextRef IO a -> ReaderT JSContextRef IO a)
-> ReaderT JSContextRef IO b)
-> ReaderT JSContextRef IO b
forall (m :: * -> *) b.
(MonadMask m, HasCallStack) =>
((forall a. m a -> m a) -> m b) -> m b
uninterruptibleMask (((forall a.
ReaderT JSContextRef IO a -> ReaderT JSContextRef IO a)
-> ReaderT JSContextRef IO b)
-> ReaderT JSContextRef IO b)
-> ((forall a.
ReaderT JSContextRef IO a -> ReaderT JSContextRef IO a)
-> ReaderT JSContextRef IO b)
-> ReaderT JSContextRef IO b
forall a b. (a -> b) -> a -> b
$ \forall a. ReaderT JSContextRef IO a -> ReaderT JSContextRef IO a
unmask -> JSM b -> ReaderT JSContextRef IO b
forall a. JSM a -> ReaderT JSContextRef IO a
unJSM ((forall a. JSM a -> JSM a) -> JSM b
a ((forall a. JSM a -> JSM a) -> JSM b)
-> (forall a. JSM a -> JSM a) -> JSM b
forall a b. (a -> b) -> a -> b
$ (ReaderT JSContextRef IO a -> ReaderT JSContextRef IO a)
-> JSM a -> JSM a
forall a.
(ReaderT JSContextRef IO a -> ReaderT JSContextRef IO a)
-> JSM a -> JSM a
q ReaderT JSContextRef IO a -> ReaderT JSContextRef IO a
forall a. ReaderT JSContextRef IO a -> ReaderT JSContextRef IO a
unmask)
where q :: (ReaderT JSContextRef IO a -> ReaderT JSContextRef IO a) -> JSM a -> JSM a
q :: forall a.
(ReaderT JSContextRef IO a -> ReaderT JSContextRef IO a)
-> JSM a -> JSM a
q ReaderT JSContextRef IO a -> ReaderT JSContextRef IO a
unmask (JSM ReaderT JSContextRef IO a
b) = JSM a -> JSM a
forall a. JSM a -> JSM a
syncAfter (JSM a -> JSM a)
-> (ReaderT JSContextRef IO a -> JSM a)
-> ReaderT JSContextRef IO a
-> JSM a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ReaderT JSContextRef IO a -> JSM a
forall a. ReaderT JSContextRef IO a -> JSM a
JSM (ReaderT JSContextRef IO a -> JSM a)
-> ReaderT JSContextRef IO a -> JSM a
forall a b. (a -> b) -> a -> b
$ ReaderT JSContextRef IO a -> ReaderT JSContextRef IO a
unmask ReaderT JSContextRef IO a
b
#if MIN_VERSION_exceptions(0,9,0)
generalBracket :: forall a b c.
HasCallStack =>
JSM a -> (a -> ExitCase b -> JSM c) -> (a -> JSM b) -> JSM (b, c)
generalBracket JSM a
acquire a -> ExitCase b -> JSM c
release a -> JSM b
use =
ReaderT JSContextRef IO (b, c) -> JSM (b, c)
forall a. ReaderT JSContextRef IO a -> JSM a
JSM (ReaderT JSContextRef IO (b, c) -> JSM (b, c))
-> ReaderT JSContextRef IO (b, c) -> JSM (b, c)
forall a b. (a -> b) -> a -> b
$ ReaderT JSContextRef IO a
-> (a -> ExitCase b -> ReaderT JSContextRef IO c)
-> (a -> ReaderT JSContextRef IO b)
-> ReaderT JSContextRef IO (b, c)
forall a b c.
HasCallStack =>
ReaderT JSContextRef IO a
-> (a -> ExitCase b -> ReaderT JSContextRef IO c)
-> (a -> ReaderT JSContextRef IO b)
-> ReaderT JSContextRef IO (b, c)
forall (m :: * -> *) a b c.
(MonadMask m, HasCallStack) =>
m a -> (a -> ExitCase b -> m c) -> (a -> m b) -> m (b, c)
generalBracket
(JSM a -> ReaderT JSContextRef IO a
forall a. JSM a -> ReaderT JSContextRef IO a
unJSM JSM a
acquire)
(\a
resource ExitCase b
exitCase -> JSM c -> ReaderT JSContextRef IO c
forall a. JSM a -> ReaderT JSContextRef IO a
unJSM (JSM c -> ReaderT JSContextRef IO c)
-> JSM c -> ReaderT JSContextRef IO c
forall a b. (a -> b) -> a -> b
$ a -> ExitCase b -> JSM c
release a
resource ExitCase b
exitCase)
(JSM b -> ReaderT JSContextRef IO b
forall a. JSM a -> ReaderT JSContextRef IO a
unJSM (JSM b -> ReaderT JSContextRef IO b)
-> (a -> JSM b) -> a -> ReaderT JSContextRef IO b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. JSM b -> JSM b
forall a. JSM a -> JSM a
syncAfter (JSM b -> JSM b) -> (a -> JSM b) -> a -> JSM b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> JSM b
use)
#endif
#endif
syncPoint :: JSM ()
#ifdef ghcjs_HOST_OS
syncPoint = return ()
#else
syncPoint :: JSM ()
syncPoint = do
Result
SyncResult <- Command -> JSM Result
sendCommand Command
Sync
() -> JSM ()
forall a. a -> JSM a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#endif
syncAfter :: JSM a -> JSM a
#ifdef ghcjs_HOST_OS
syncAfter = id
#else
syncAfter :: forall a. JSM a -> JSM a
syncAfter JSM a
f = do
a
result <- JSM a
f
JSM ()
syncPoint
a -> JSM a
forall a. a -> JSM a
forall (m :: * -> *) a. Monad m => a -> m a
return a
result
#endif
#ifndef ghcjs_HOST_OS
sendCommand :: Command -> JSM Result
sendCommand :: Command -> JSM Result
sendCommand Command
cmd = do
Command -> IO Result
s <- JSContextRef -> Command -> IO Result
doSendCommand (JSContextRef -> Command -> IO Result)
-> JSM JSContextRef -> JSM (Command -> IO Result)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ReaderT JSContextRef IO JSContextRef -> JSM JSContextRef
forall a. ReaderT JSContextRef IO a -> JSM a
JSM ReaderT JSContextRef IO JSContextRef
forall (m :: * -> *) r. Monad m => ReaderT r m r
ask
IO Result -> JSM Result
forall a. IO a -> JSM a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Result -> JSM Result) -> IO Result -> JSM Result
forall a b. (a -> b) -> a -> b
$ Command -> IO Result
s Command
cmd
#endif
#ifdef ghcjs_HOST_OS
type GHCJSPure a = a
#else
newtype GHCJSPure a = GHCJSPure (JSM a)
#endif
ghcjsPure :: GHCJSPure a -> JSM a
#ifdef ghcjs_HOST_OS
ghcjsPure = pure
#else
ghcjsPure :: forall a. GHCJSPure a -> JSM a
ghcjsPure (GHCJSPure JSM a
x) = JSM a
x
#endif
{-# INLINE ghcjsPure #-}
ghcjsPureMap :: (a -> b) -> GHCJSPure a -> GHCJSPure b
#ifdef ghcjs_HOST_OS
ghcjsPureMap = id
#else
ghcjsPureMap :: forall a b. (a -> b) -> GHCJSPure a -> GHCJSPure b
ghcjsPureMap a -> b
f (GHCJSPure JSM a
x) = JSM b -> GHCJSPure b
forall a. JSM a -> GHCJSPure a
GHCJSPure (a -> b
f (a -> b) -> JSM a -> JSM b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> JSM a
x)
#endif
{-# INLINE ghcjsPureMap #-}
ghcjsPureId :: a -> GHCJSPure a
#ifdef ghcjs_HOST_OS
ghcjsPureId = id
#else
ghcjsPureId :: forall a. a -> GHCJSPure a
ghcjsPureId = JSM a -> GHCJSPure a
forall a. JSM a -> GHCJSPure a
GHCJSPure (JSM a -> GHCJSPure a) -> (a -> JSM a) -> a -> GHCJSPure a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> JSM a
forall a. a -> JSM a
forall (m :: * -> *) a. Monad m => a -> m a
return
#endif
{-# INLINE ghcjsPureId #-}
#ifdef ghcjs_HOST_OS
type MonadJSM = MonadIO
#else
class (Applicative m, MonadIO m) => MonadJSM m where
liftJSM' :: JSM a -> m a
default liftJSM' :: (MonadJSM m', MonadTrans t, m ~ t m') => JSM a -> m a
liftJSM' = m' a -> m a
m' a -> t m' a
forall (m :: * -> *) a. Monad m => m a -> t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m' a -> m a) -> (JSM a -> m' a) -> JSM a -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (JSM a -> m' a
forall a. JSM a -> m' a
forall (m :: * -> *) a. MonadJSM m => JSM a -> m a
forall {m' :: * -> *} {a}. MonadJSM m' => JSM a -> m' a
liftJSM' :: MonadJSM m' => JSM a -> m' a)
{-# INLINE liftJSM' #-}
instance MonadJSM JSM where
liftJSM' :: forall a. JSM a -> JSM a
liftJSM' = JSM a -> JSM a
forall a. a -> a
id
{-# INLINE liftJSM' #-}
instance (MonadJSM m) => MonadJSM (ContT r m) where
liftJSM' :: forall a. JSM a -> ContT r m a
liftJSM' = m a -> ContT r m a
forall (m :: * -> *) a. Monad m => m a -> ContT r m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> ContT r m a) -> (JSM a -> m a) -> JSM a -> ContT r m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. JSM a -> m a
forall a. JSM a -> m a
forall (m :: * -> *) a. MonadJSM m => JSM a -> m a
liftJSM'
{-# INLINE liftJSM' #-}
instance (MonadJSM m) => MonadJSM (ExceptT e m) where
liftJSM' :: forall a. JSM a -> ExceptT e m a
liftJSM' = m a -> ExceptT e m a
forall (m :: * -> *) a. Monad m => m a -> ExceptT e m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> ExceptT e m a) -> (JSM a -> m a) -> JSM a -> ExceptT e m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. JSM a -> m a
forall a. JSM a -> m a
forall (m :: * -> *) a. MonadJSM m => JSM a -> m a
liftJSM'
{-# INLINE liftJSM' #-}
instance (MonadJSM m) => MonadJSM (IdentityT m) where
liftJSM' :: forall a. JSM a -> IdentityT m a
liftJSM' = m a -> IdentityT m a
forall (m :: * -> *) a. Monad m => m a -> IdentityT m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> IdentityT m a) -> (JSM a -> m a) -> JSM a -> IdentityT m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. JSM a -> m a
forall a. JSM a -> m a
forall (m :: * -> *) a. MonadJSM m => JSM a -> m a
liftJSM'
{-# INLINE liftJSM' #-}
instance (MonadJSM m) => MonadJSM (MaybeT m) where
liftJSM' :: forall a. JSM a -> MaybeT m a
liftJSM' = m a -> MaybeT m a
forall (m :: * -> *) a. Monad m => m a -> MaybeT m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> MaybeT m a) -> (JSM a -> m a) -> JSM a -> MaybeT m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. JSM a -> m a
forall a. JSM a -> m a
forall (m :: * -> *) a. MonadJSM m => JSM a -> m a
liftJSM'
{-# INLINE liftJSM' #-}
instance (MonadJSM m) => MonadJSM (ReaderT r m) where
liftJSM' :: forall a. JSM a -> ReaderT r m a
liftJSM' = m a -> ReaderT r m a
forall (m :: * -> *) a. Monad m => m a -> ReaderT r m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> ReaderT r m a) -> (JSM a -> m a) -> JSM a -> ReaderT r m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. JSM a -> m a
forall a. JSM a -> m a
forall (m :: * -> *) a. MonadJSM m => JSM a -> m a
liftJSM'
{-# INLINE liftJSM' #-}
instance (Monoid w, MonadJSM m) => MonadJSM (Lazy.RWST r w s m) where
liftJSM' :: forall a. JSM a -> RWST r w s m a
liftJSM' = m a -> RWST r w s m a
forall (m :: * -> *) a. Monad m => m a -> RWST r w s m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> RWST r w s m a)
-> (JSM a -> m a) -> JSM a -> RWST r w s m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. JSM a -> m a
forall a. JSM a -> m a
forall (m :: * -> *) a. MonadJSM m => JSM a -> m a
liftJSM'
{-# INLINE liftJSM' #-}
instance (Monoid w, MonadJSM m) => MonadJSM (Strict.RWST r w s m) where
liftJSM' :: forall a. JSM a -> RWST r w s m a
liftJSM' = m a -> RWST r w s m a
forall (m :: * -> *) a. Monad m => m a -> RWST r w s m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> RWST r w s m a)
-> (JSM a -> m a) -> JSM a -> RWST r w s m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. JSM a -> m a
forall a. JSM a -> m a
forall (m :: * -> *) a. MonadJSM m => JSM a -> m a
liftJSM'
{-# INLINE liftJSM' #-}
instance (MonadJSM m) => MonadJSM (Lazy.StateT s m) where
liftJSM' :: forall a. JSM a -> StateT s m a
liftJSM' = m a -> StateT s m a
forall (m :: * -> *) a. Monad m => m a -> StateT s m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> StateT s m a) -> (JSM a -> m a) -> JSM a -> StateT s m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. JSM a -> m a
forall a. JSM a -> m a
forall (m :: * -> *) a. MonadJSM m => JSM a -> m a
liftJSM'
{-# INLINE liftJSM' #-}
instance (MonadJSM m) => MonadJSM (Strict.StateT s m) where
liftJSM' :: forall a. JSM a -> StateT s m a
liftJSM' = m a -> StateT s m a
forall (m :: * -> *) a. Monad m => m a -> StateT s m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> StateT s m a) -> (JSM a -> m a) -> JSM a -> StateT s m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. JSM a -> m a
forall a. JSM a -> m a
forall (m :: * -> *) a. MonadJSM m => JSM a -> m a
liftJSM'
{-# INLINE liftJSM' #-}
instance (Monoid w, MonadJSM m) => MonadJSM (Lazy.WriterT w m) where
liftJSM' :: forall a. JSM a -> WriterT w m a
liftJSM' = m a -> WriterT w m a
forall (m :: * -> *) a. Monad m => m a -> WriterT w m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> WriterT w m a) -> (JSM a -> m a) -> JSM a -> WriterT w m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. JSM a -> m a
forall a. JSM a -> m a
forall (m :: * -> *) a. MonadJSM m => JSM a -> m a
liftJSM'
{-# INLINE liftJSM' #-}
instance (Monoid w, MonadJSM m) => MonadJSM (Strict.WriterT w m) where
liftJSM' :: forall a. JSM a -> WriterT w m a
liftJSM' = m a -> WriterT w m a
forall (m :: * -> *) a. Monad m => m a -> WriterT w m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> WriterT w m a) -> (JSM a -> m a) -> JSM a -> WriterT w m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. JSM a -> m a
forall a. JSM a -> m a
forall (m :: * -> *) a. MonadJSM m => JSM a -> m a
liftJSM'
{-# INLINE liftJSM' #-}
instance MonadRef JSM where
type Ref JSM = Ref IO
newRef :: forall a. a -> JSM (Ref JSM a)
newRef = IO (IORef a) -> JSM (IORef a)
forall a. IO a -> JSM a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (IORef a) -> JSM (IORef a))
-> (a -> IO (IORef a)) -> a -> JSM (IORef a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> IO (IORef a)
a -> IO (Ref IO a)
forall a. a -> IO (Ref IO a)
forall (m :: * -> *) a. MonadRef m => a -> m (Ref m a)
newRef
readRef :: forall a. Ref JSM a -> JSM a
readRef = IO a -> JSM a
forall a. IO a -> JSM a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO a -> JSM a) -> (IORef a -> IO a) -> IORef a -> JSM a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IORef a -> IO a
Ref IO a -> IO a
forall a. Ref IO a -> IO a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef
writeRef :: forall a. Ref JSM a -> a -> JSM ()
writeRef Ref JSM a
r = IO () -> JSM ()
forall a. IO a -> JSM a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> JSM ()) -> (a -> IO ()) -> a -> JSM ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ref IO a -> a -> IO ()
forall a. Ref IO a -> a -> IO ()
forall (m :: * -> *) a. MonadRef m => Ref m a -> a -> m ()
writeRef Ref IO a
Ref JSM a
r
instance MonadAtomicRef JSM where
atomicModifyRef :: forall a b. Ref JSM a -> (a -> (a, b)) -> JSM b
atomicModifyRef Ref JSM a
r = IO b -> JSM b
forall a. IO a -> JSM a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO b -> JSM b)
-> ((a -> (a, b)) -> IO b) -> (a -> (a, b)) -> JSM b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ref IO a -> (a -> (a, b)) -> IO b
forall a b. Ref IO a -> (a -> (a, b)) -> IO b
forall (m :: * -> *) a b.
MonadAtomicRef m =>
Ref m a -> (a -> (a, b)) -> m b
atomicModifyRef Ref IO a
Ref JSM a
r
#endif
liftJSM :: MonadJSM m => JSM a -> m a
#ifdef ghcjs_HOST_OS
liftJSM = liftIO
#else
liftJSM :: forall {m' :: * -> *} {a}. MonadJSM m' => JSM a -> m' a
liftJSM = JSM a -> m a
forall a. JSM a -> m a
forall (m :: * -> *) a. MonadJSM m => JSM a -> m a
liftJSM'
#endif
{-# INLINE liftJSM #-}
type JSCallAsFunction = JSVal
-> JSVal
-> [JSVal]
-> JSM ()
#ifndef ghcjs_HOST_OS
class IsJSVal a where
jsval_ :: a -> GHCJSPure JSVal
default jsval_ :: Coercible a JSVal => a -> GHCJSPure JSVal
jsval_ = JSM JSVal -> GHCJSPure JSVal
forall a. JSM a -> GHCJSPure a
GHCJSPure (JSM JSVal -> GHCJSPure JSVal)
-> (a -> JSM JSVal) -> a -> GHCJSPure JSVal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. JSVal -> JSM JSVal
forall a. a -> JSM a
forall (m :: * -> *) a. Monad m => a -> m a
return (JSVal -> JSM JSVal) -> (a -> JSVal) -> a -> JSM JSVal
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> JSVal
forall a b. Coercible a b => a -> b
coerce
{-# INLINE jsval_ #-}
jsval :: IsJSVal a => a -> GHCJSPure JSVal
jsval :: forall a. IsJSVal a => a -> GHCJSPure JSVal
jsval = a -> GHCJSPure JSVal
forall a. IsJSVal a => a -> GHCJSPure JSVal
jsval_
{-# INLINE jsval #-}
data MutabilityType s = Mutable_ s
| Immutable_ s
| STMutable s
type Mutable = Mutable_ ()
type Immutable = Immutable_ ()
data IsItMutable = IsImmutable
| IsMutable
type family Mutability (a :: MutabilityType s) :: IsItMutable where
Mutability Immutable = IsImmutable
Mutability Mutable = IsMutable
Mutability (STMutable s) = IsMutable
newtype SomeJSArray (m :: MutabilityType s) = SomeJSArray JSVal
deriving (Typeable)
instance IsJSVal (SomeJSArray m)
type JSArray = SomeJSArray Immutable
type MutableJSArray = SomeJSArray Mutable
type STJSArray s = SomeJSArray (STMutable s)
newtype Object = Object JSVal
newtype Nullable a = Nullable a
newtype JSValueReceived = JSValueReceived JSValueRef deriving(Int -> JSValueReceived -> ShowS
[JSValueReceived] -> ShowS
JSValueReceived -> String
(Int -> JSValueReceived -> ShowS)
-> (JSValueReceived -> String)
-> ([JSValueReceived] -> ShowS)
-> Show JSValueReceived
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> JSValueReceived -> ShowS
showsPrec :: Int -> JSValueReceived -> ShowS
$cshow :: JSValueReceived -> String
show :: JSValueReceived -> String
$cshowList :: [JSValueReceived] -> ShowS
showList :: [JSValueReceived] -> ShowS
Show, [JSValueReceived] -> Value
[JSValueReceived] -> Encoding
JSValueReceived -> Bool
JSValueReceived -> Value
JSValueReceived -> Encoding
(JSValueReceived -> Value)
-> (JSValueReceived -> Encoding)
-> ([JSValueReceived] -> Value)
-> ([JSValueReceived] -> Encoding)
-> (JSValueReceived -> Bool)
-> ToJSON JSValueReceived
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: JSValueReceived -> Value
toJSON :: JSValueReceived -> Value
$ctoEncoding :: JSValueReceived -> Encoding
toEncoding :: JSValueReceived -> Encoding
$ctoJSONList :: [JSValueReceived] -> Value
toJSONList :: [JSValueReceived] -> Value
$ctoEncodingList :: [JSValueReceived] -> Encoding
toEncodingList :: [JSValueReceived] -> Encoding
$comitField :: JSValueReceived -> Bool
omitField :: JSValueReceived -> Bool
ToJSON, Maybe JSValueReceived
Value -> Parser [JSValueReceived]
Value -> Parser JSValueReceived
(Value -> Parser JSValueReceived)
-> (Value -> Parser [JSValueReceived])
-> Maybe JSValueReceived
-> FromJSON JSValueReceived
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser JSValueReceived
parseJSON :: Value -> Parser JSValueReceived
$cparseJSONList :: Value -> Parser [JSValueReceived]
parseJSONList :: Value -> Parser [JSValueReceived]
$comittedField :: Maybe JSValueReceived
omittedField :: Maybe JSValueReceived
FromJSON)
newtype JSValueForSend = JSValueForSend JSValueRef deriving(Int -> JSValueForSend -> ShowS
[JSValueForSend] -> ShowS
JSValueForSend -> String
(Int -> JSValueForSend -> ShowS)
-> (JSValueForSend -> String)
-> ([JSValueForSend] -> ShowS)
-> Show JSValueForSend
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> JSValueForSend -> ShowS
showsPrec :: Int -> JSValueForSend -> ShowS
$cshow :: JSValueForSend -> String
show :: JSValueForSend -> String
$cshowList :: [JSValueForSend] -> ShowS
showList :: [JSValueForSend] -> ShowS
Show, [JSValueForSend] -> Value
[JSValueForSend] -> Encoding
JSValueForSend -> Bool
JSValueForSend -> Value
JSValueForSend -> Encoding
(JSValueForSend -> Value)
-> (JSValueForSend -> Encoding)
-> ([JSValueForSend] -> Value)
-> ([JSValueForSend] -> Encoding)
-> (JSValueForSend -> Bool)
-> ToJSON JSValueForSend
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: JSValueForSend -> Value
toJSON :: JSValueForSend -> Value
$ctoEncoding :: JSValueForSend -> Encoding
toEncoding :: JSValueForSend -> Encoding
$ctoJSONList :: [JSValueForSend] -> Value
toJSONList :: [JSValueForSend] -> Value
$ctoEncodingList :: [JSValueForSend] -> Encoding
toEncodingList :: [JSValueForSend] -> Encoding
$comitField :: JSValueForSend -> Bool
omitField :: JSValueForSend -> Bool
ToJSON, Maybe JSValueForSend
Value -> Parser [JSValueForSend]
Value -> Parser JSValueForSend
(Value -> Parser JSValueForSend)
-> (Value -> Parser [JSValueForSend])
-> Maybe JSValueForSend
-> FromJSON JSValueForSend
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser JSValueForSend
parseJSON :: Value -> Parser JSValueForSend
$cparseJSONList :: Value -> Parser [JSValueForSend]
parseJSONList :: Value -> Parser [JSValueForSend]
$comittedField :: Maybe JSValueForSend
omittedField :: Maybe JSValueForSend
FromJSON, (forall x. JSValueForSend -> Rep JSValueForSend x)
-> (forall x. Rep JSValueForSend x -> JSValueForSend)
-> Generic JSValueForSend
forall x. Rep JSValueForSend x -> JSValueForSend
forall x. JSValueForSend -> Rep JSValueForSend x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. JSValueForSend -> Rep JSValueForSend x
from :: forall x. JSValueForSend -> Rep JSValueForSend x
$cto :: forall x. Rep JSValueForSend x -> JSValueForSend
to :: forall x. Rep JSValueForSend x -> JSValueForSend
Generic)
instance NFData JSValueForSend
newtype JSObjectForSend = JSObjectForSend JSValueForSend deriving(Int -> JSObjectForSend -> ShowS
[JSObjectForSend] -> ShowS
JSObjectForSend -> String
(Int -> JSObjectForSend -> ShowS)
-> (JSObjectForSend -> String)
-> ([JSObjectForSend] -> ShowS)
-> Show JSObjectForSend
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> JSObjectForSend -> ShowS
showsPrec :: Int -> JSObjectForSend -> ShowS
$cshow :: JSObjectForSend -> String
show :: JSObjectForSend -> String
$cshowList :: [JSObjectForSend] -> ShowS
showList :: [JSObjectForSend] -> ShowS
Show, [JSObjectForSend] -> Value
[JSObjectForSend] -> Encoding
JSObjectForSend -> Bool
JSObjectForSend -> Value
JSObjectForSend -> Encoding
(JSObjectForSend -> Value)
-> (JSObjectForSend -> Encoding)
-> ([JSObjectForSend] -> Value)
-> ([JSObjectForSend] -> Encoding)
-> (JSObjectForSend -> Bool)
-> ToJSON JSObjectForSend
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: JSObjectForSend -> Value
toJSON :: JSObjectForSend -> Value
$ctoEncoding :: JSObjectForSend -> Encoding
toEncoding :: JSObjectForSend -> Encoding
$ctoJSONList :: [JSObjectForSend] -> Value
toJSONList :: [JSObjectForSend] -> Value
$ctoEncodingList :: [JSObjectForSend] -> Encoding
toEncodingList :: [JSObjectForSend] -> Encoding
$comitField :: JSObjectForSend -> Bool
omitField :: JSObjectForSend -> Bool
ToJSON, Maybe JSObjectForSend
Value -> Parser [JSObjectForSend]
Value -> Parser JSObjectForSend
(Value -> Parser JSObjectForSend)
-> (Value -> Parser [JSObjectForSend])
-> Maybe JSObjectForSend
-> FromJSON JSObjectForSend
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser JSObjectForSend
parseJSON :: Value -> Parser JSObjectForSend
$cparseJSONList :: Value -> Parser [JSObjectForSend]
parseJSONList :: Value -> Parser [JSObjectForSend]
$comittedField :: Maybe JSObjectForSend
omittedField :: Maybe JSObjectForSend
FromJSON, (forall x. JSObjectForSend -> Rep JSObjectForSend x)
-> (forall x. Rep JSObjectForSend x -> JSObjectForSend)
-> Generic JSObjectForSend
forall x. Rep JSObjectForSend x -> JSObjectForSend
forall x. JSObjectForSend -> Rep JSObjectForSend x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. JSObjectForSend -> Rep JSObjectForSend x
from :: forall x. JSObjectForSend -> Rep JSObjectForSend x
$cto :: forall x. Rep JSObjectForSend x -> JSObjectForSend
to :: forall x. Rep JSObjectForSend x -> JSObjectForSend
Generic)
instance NFData JSObjectForSend
newtype JSStringReceived = JSStringReceived Text deriving(Int -> JSStringReceived -> ShowS
[JSStringReceived] -> ShowS
JSStringReceived -> String
(Int -> JSStringReceived -> ShowS)
-> (JSStringReceived -> String)
-> ([JSStringReceived] -> ShowS)
-> Show JSStringReceived
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> JSStringReceived -> ShowS
showsPrec :: Int -> JSStringReceived -> ShowS
$cshow :: JSStringReceived -> String
show :: JSStringReceived -> String
$cshowList :: [JSStringReceived] -> ShowS
showList :: [JSStringReceived] -> ShowS
Show, [JSStringReceived] -> Value
[JSStringReceived] -> Encoding
JSStringReceived -> Bool
JSStringReceived -> Value
JSStringReceived -> Encoding
(JSStringReceived -> Value)
-> (JSStringReceived -> Encoding)
-> ([JSStringReceived] -> Value)
-> ([JSStringReceived] -> Encoding)
-> (JSStringReceived -> Bool)
-> ToJSON JSStringReceived
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: JSStringReceived -> Value
toJSON :: JSStringReceived -> Value
$ctoEncoding :: JSStringReceived -> Encoding
toEncoding :: JSStringReceived -> Encoding
$ctoJSONList :: [JSStringReceived] -> Value
toJSONList :: [JSStringReceived] -> Value
$ctoEncodingList :: [JSStringReceived] -> Encoding
toEncodingList :: [JSStringReceived] -> Encoding
$comitField :: JSStringReceived -> Bool
omitField :: JSStringReceived -> Bool
ToJSON, Maybe JSStringReceived
Value -> Parser [JSStringReceived]
Value -> Parser JSStringReceived
(Value -> Parser JSStringReceived)
-> (Value -> Parser [JSStringReceived])
-> Maybe JSStringReceived
-> FromJSON JSStringReceived
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser JSStringReceived
parseJSON :: Value -> Parser JSStringReceived
$cparseJSONList :: Value -> Parser [JSStringReceived]
parseJSONList :: Value -> Parser [JSStringReceived]
$comittedField :: Maybe JSStringReceived
omittedField :: Maybe JSStringReceived
FromJSON)
newtype JSStringForSend = JSStringForSend Text deriving(Int -> JSStringForSend -> ShowS
[JSStringForSend] -> ShowS
JSStringForSend -> String
(Int -> JSStringForSend -> ShowS)
-> (JSStringForSend -> String)
-> ([JSStringForSend] -> ShowS)
-> Show JSStringForSend
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> JSStringForSend -> ShowS
showsPrec :: Int -> JSStringForSend -> ShowS
$cshow :: JSStringForSend -> String
show :: JSStringForSend -> String
$cshowList :: [JSStringForSend] -> ShowS
showList :: [JSStringForSend] -> ShowS
Show, [JSStringForSend] -> Value
[JSStringForSend] -> Encoding
JSStringForSend -> Bool
JSStringForSend -> Value
JSStringForSend -> Encoding
(JSStringForSend -> Value)
-> (JSStringForSend -> Encoding)
-> ([JSStringForSend] -> Value)
-> ([JSStringForSend] -> Encoding)
-> (JSStringForSend -> Bool)
-> ToJSON JSStringForSend
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: JSStringForSend -> Value
toJSON :: JSStringForSend -> Value
$ctoEncoding :: JSStringForSend -> Encoding
toEncoding :: JSStringForSend -> Encoding
$ctoJSONList :: [JSStringForSend] -> Value
toJSONList :: [JSStringForSend] -> Value
$ctoEncodingList :: [JSStringForSend] -> Encoding
toEncodingList :: [JSStringForSend] -> Encoding
$comitField :: JSStringForSend -> Bool
omitField :: JSStringForSend -> Bool
ToJSON, Maybe JSStringForSend
Value -> Parser [JSStringForSend]
Value -> Parser JSStringForSend
(Value -> Parser JSStringForSend)
-> (Value -> Parser [JSStringForSend])
-> Maybe JSStringForSend
-> FromJSON JSStringForSend
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser JSStringForSend
parseJSON :: Value -> Parser JSStringForSend
$cparseJSONList :: Value -> Parser [JSStringForSend]
parseJSONList :: Value -> Parser [JSStringForSend]
$comittedField :: Maybe JSStringForSend
omittedField :: Maybe JSStringForSend
FromJSON, (forall x. JSStringForSend -> Rep JSStringForSend x)
-> (forall x. Rep JSStringForSend x -> JSStringForSend)
-> Generic JSStringForSend
forall x. Rep JSStringForSend x -> JSStringForSend
forall x. JSStringForSend -> Rep JSStringForSend x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. JSStringForSend -> Rep JSStringForSend x
from :: forall x. JSStringForSend -> Rep JSStringForSend x
$cto :: forall x. Rep JSStringForSend x -> JSStringForSend
to :: forall x. Rep JSStringForSend x -> JSStringForSend
Generic)
instance NFData JSStringForSend
data AsyncCommand = FreeRef Text JSValueForSend
| FreeRefs Text
| SetPropertyByName JSObjectForSend JSStringForSend JSValueForSend
| SetPropertyAtIndex JSObjectForSend Int JSValueForSend
| StringToValue JSStringForSend JSValueForSend
| NumberToValue Double JSValueForSend
| JSONValueToValue Value JSValueForSend
| GetPropertyByName JSObjectForSend JSStringForSend JSValueForSend
| GetPropertyAtIndex JSObjectForSend Int JSValueForSend
| CallAsFunction JSObjectForSend JSObjectForSend [JSValueForSend] JSValueForSend
| CallAsConstructor JSObjectForSend [JSValueForSend] JSValueForSend
| NewEmptyObject JSValueForSend
| NewAsyncCallback JSValueForSend
| NewSyncCallback JSValueForSend
| FreeCallback JSValueForSend
| NewArray [JSValueForSend] JSValueForSend
| EvaluateScript JSStringForSend JSValueForSend
| SyncWithAnimationFrame JSValueForSend
| StartSyncBlock
| EndSyncBlock
deriving (Int -> AsyncCommand -> ShowS
[AsyncCommand] -> ShowS
AsyncCommand -> String
(Int -> AsyncCommand -> ShowS)
-> (AsyncCommand -> String)
-> ([AsyncCommand] -> ShowS)
-> Show AsyncCommand
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AsyncCommand -> ShowS
showsPrec :: Int -> AsyncCommand -> ShowS
$cshow :: AsyncCommand -> String
show :: AsyncCommand -> String
$cshowList :: [AsyncCommand] -> ShowS
showList :: [AsyncCommand] -> ShowS
Show, (forall x. AsyncCommand -> Rep AsyncCommand x)
-> (forall x. Rep AsyncCommand x -> AsyncCommand)
-> Generic AsyncCommand
forall x. Rep AsyncCommand x -> AsyncCommand
forall x. AsyncCommand -> Rep AsyncCommand x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. AsyncCommand -> Rep AsyncCommand x
from :: forall x. AsyncCommand -> Rep AsyncCommand x
$cto :: forall x. Rep AsyncCommand x -> AsyncCommand
to :: forall x. Rep AsyncCommand x -> AsyncCommand
Generic)
instance ToJSON AsyncCommand where
toEncoding :: AsyncCommand -> Encoding
toEncoding = Options -> AsyncCommand -> Encoding
forall a.
(Generic a, GToJSON' Encoding Zero (Rep a)) =>
Options -> a -> Encoding
genericToEncoding Options
defaultOptions
instance FromJSON AsyncCommand
instance NFData AsyncCommand
data Command = DeRefVal JSValueForSend
| ValueToBool JSValueForSend
| ValueToNumber JSValueForSend
| ValueToString JSValueForSend
| ValueToJSON JSValueForSend
| ValueToJSONValue JSValueForSend
| IsNull JSValueForSend
| IsUndefined JSValueForSend
| StrictEqual JSValueForSend JSValueForSend
| InstanceOf JSValueForSend JSObjectForSend
| PropertyNames JSObjectForSend
| Sync
deriving (Int -> Command -> ShowS
[Command] -> ShowS
Command -> String
(Int -> Command -> ShowS)
-> (Command -> String) -> ([Command] -> ShowS) -> Show Command
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Command -> ShowS
showsPrec :: Int -> Command -> ShowS
$cshow :: Command -> String
show :: Command -> String
$cshowList :: [Command] -> ShowS
showList :: [Command] -> ShowS
Show, (forall x. Command -> Rep Command x)
-> (forall x. Rep Command x -> Command) -> Generic Command
forall x. Rep Command x -> Command
forall x. Command -> Rep Command x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Command -> Rep Command x
from :: forall x. Command -> Rep Command x
$cto :: forall x. Rep Command x -> Command
to :: forall x. Rep Command x -> Command
Generic)
instance ToJSON Command where
toEncoding :: Command -> Encoding
toEncoding = Options -> Command -> Encoding
forall a.
(Generic a, GToJSON' Encoding Zero (Rep a)) =>
Options -> a -> Encoding
genericToEncoding Options
defaultOptions
instance FromJSON Command
instance NFData Command
data Batch = Batch [Either AsyncCommand Command] Bool Int
deriving (Int -> Batch -> ShowS
[Batch] -> ShowS
Batch -> String
(Int -> Batch -> ShowS)
-> (Batch -> String) -> ([Batch] -> ShowS) -> Show Batch
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Batch -> ShowS
showsPrec :: Int -> Batch -> ShowS
$cshow :: Batch -> String
show :: Batch -> String
$cshowList :: [Batch] -> ShowS
showList :: [Batch] -> ShowS
Show, (forall x. Batch -> Rep Batch x)
-> (forall x. Rep Batch x -> Batch) -> Generic Batch
forall x. Rep Batch x -> Batch
forall x. Batch -> Rep Batch x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Batch -> Rep Batch x
from :: forall x. Batch -> Rep Batch x
$cto :: forall x. Rep Batch x -> Batch
to :: forall x. Rep Batch x -> Batch
Generic)
instance ToJSON Batch where
toEncoding :: Batch -> Encoding
toEncoding = Options -> Batch -> Encoding
forall a.
(Generic a, GToJSON' Encoding Zero (Rep a)) =>
Options -> a -> Encoding
genericToEncoding Options
defaultOptions
instance FromJSON Batch
instance NFData Batch
data Result = DeRefValResult JSValueRef Text
| ValueToBoolResult Bool
| ValueToNumberResult Double
| ValueToStringResult JSStringReceived
| ValueToJSONResult JSStringReceived
| ValueToJSONValueResult Value
| IsNullResult Bool
| IsUndefinedResult Bool
| StrictEqualResult Bool
| InstanceOfResult Bool
| PropertyNamesResult [JSStringReceived]
| ThrowJSValue JSValueReceived
| SyncResult
deriving (Int -> Result -> ShowS
[Result] -> ShowS
Result -> String
(Int -> Result -> ShowS)
-> (Result -> String) -> ([Result] -> ShowS) -> Show Result
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Result -> ShowS
showsPrec :: Int -> Result -> ShowS
$cshow :: Result -> String
show :: Result -> String
$cshowList :: [Result] -> ShowS
showList :: [Result] -> ShowS
Show, (forall x. Result -> Rep Result x)
-> (forall x. Rep Result x -> Result) -> Generic Result
forall x. Rep Result x -> Result
forall x. Result -> Rep Result x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Result -> Rep Result x
from :: forall x. Result -> Rep Result x
$cto :: forall x. Rep Result x -> Result
to :: forall x. Rep Result x -> Result
Generic)
instance ToJSON Result where
toEncoding :: Result -> Encoding
toEncoding = Options -> Result -> Encoding
forall a.
(Generic a, GToJSON' Encoding Zero (Rep a)) =>
Options -> a -> Encoding
genericToEncoding Options
defaultOptions
instance FromJSON Result
data BatchResults = Success [JSValueReceived] [Result]
| Failure [JSValueReceived] [Result] JSValueReceived String
deriving (Int -> BatchResults -> ShowS
[BatchResults] -> ShowS
BatchResults -> String
(Int -> BatchResults -> ShowS)
-> (BatchResults -> String)
-> ([BatchResults] -> ShowS)
-> Show BatchResults
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BatchResults -> ShowS
showsPrec :: Int -> BatchResults -> ShowS
$cshow :: BatchResults -> String
show :: BatchResults -> String
$cshowList :: [BatchResults] -> ShowS
showList :: [BatchResults] -> ShowS
Show, (forall x. BatchResults -> Rep BatchResults x)
-> (forall x. Rep BatchResults x -> BatchResults)
-> Generic BatchResults
forall x. Rep BatchResults x -> BatchResults
forall x. BatchResults -> Rep BatchResults x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. BatchResults -> Rep BatchResults x
from :: forall x. BatchResults -> Rep BatchResults x
$cto :: forall x. Rep BatchResults x -> BatchResults
to :: forall x. Rep BatchResults x -> BatchResults
Generic)
instance ToJSON BatchResults where
toEncoding :: BatchResults -> Encoding
toEncoding = Options -> BatchResults -> Encoding
forall a.
(Generic a, GToJSON' Encoding Zero (Rep a)) =>
Options -> a -> Encoding
genericToEncoding Options
defaultOptions
instance FromJSON BatchResults
data Results = BatchResults Int BatchResults
| Duplicate Int Int
| Callback Int BatchResults JSValueReceived JSValueReceived JSValueReceived [JSValueReceived]
| ProtocolError Text
deriving (Int -> Results -> ShowS
[Results] -> ShowS
Results -> String
(Int -> Results -> ShowS)
-> (Results -> String) -> ([Results] -> ShowS) -> Show Results
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Results -> ShowS
showsPrec :: Int -> Results -> ShowS
$cshow :: Results -> String
show :: Results -> String
$cshowList :: [Results] -> ShowS
showList :: [Results] -> ShowS
Show, (forall x. Results -> Rep Results x)
-> (forall x. Rep Results x -> Results) -> Generic Results
forall x. Rep Results x -> Results
forall x. Results -> Rep Results x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Results -> Rep Results x
from :: forall x. Results -> Rep Results x
$cto :: forall x. Rep Results x -> Results
to :: forall x. Rep Results x -> Results
Generic)
instance ToJSON Results where
toEncoding :: Results -> Encoding
toEncoding = Options -> Results -> Encoding
forall a.
(Generic a, GToJSON' Encoding Zero (Rep a)) =>
Options -> a -> Encoding
genericToEncoding Options
defaultOptions
instance FromJSON Results
#endif
#if MIN_VERSION_base(4,9,0) && defined(CHECK_UNCHECKED)
type JSadddleHasCallStack = HasCallStack
#else
type JSadddleHasCallStack = (() :: Constraint)
#endif