{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE EmptyCase #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE RecursiveDo #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE UndecidableSuperClasses #-}

-- | Render the first widget on the server, and the second on the client.
module Reflex.Dom.Prerender
       ( Prerender (..)
       , prerender_
       , PrerenderClientConstraint
       , PrerenderBaseConstraints
       ) where

import Control.Monad.Primitive (PrimMonad(..))
import Control.Monad.Reader
import Control.Monad.Ref (MonadRef(..), MonadAtomicRef(..))
import Data.IORef (IORef, newIORef)
import Data.Semigroup (Semigroup)
import Data.Text (Text)
import Data.Void
import Foreign.JavaScript.TH
import GHCJS.DOM.Types (MonadJSM)
import Reflex hiding (askEvents)
import Reflex.Dom.Builder.Class
import Reflex.Dom.Builder.Hydratable
import Reflex.Dom.Builder.Immediate
import Reflex.Dom.Builder.InputDisabled
import Reflex.Dom.Builder.Static
import Reflex.Host.Class
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IntMap

import qualified GHCJS.DOM.Document as Document
import qualified GHCJS.DOM.Node as Node
import qualified GHCJS.DOM.Types as DOM

type PrerenderClientConstraint js t m =
  ( DomBuilder t m
  , DomBuilderSpace m ~ GhcjsDomSpace
  , DomRenderHook t m
  , HasDocument m
  , TriggerEvent t m
  , PrerenderBaseConstraints js t m
  )

type PrerenderBaseConstraints js t m =
  ( HasJSContext (Performable m)
  , HasJSContext m
  , MonadFix m
  , MonadHold t m
  , MonadJSM (Performable m)
  , MonadJSM m
  , MonadRef (Performable m)
  , MonadRef m
  , MonadReflexCreateTrigger t m
  , MonadSample t (Performable m)
  , PerformEvent t m
  , PostBuild t m
  , PrimMonad m
  , Ref (Performable m) ~ IORef
  , Ref m ~ IORef
  , HasJS js m
  , HasJS js (Performable m)
  )

-- | Render the first widget on the server, and the second on the client. The
-- hydration builder will run *both* widgets.
prerender_
  :: (Functor m, Reflex t, Prerender js t m)
  => m () ->  Client m () -> m ()
prerender_ :: m () -> Client m () -> m ()
prerender_ m ()
server Client m ()
client = m (Dynamic t ()) -> m ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (m (Dynamic t ()) -> m ()) -> m (Dynamic t ()) -> m ()
forall a b. (a -> b) -> a -> b
$ m () -> Client m () -> m (Dynamic t ())
forall js t (m :: * -> *) a.
Prerender js t m =>
m a -> Client m a -> m (Dynamic t a)
prerender m ()
server Client m ()
client

class (PrerenderClientConstraint js t (Client m), Client (Client m) ~ Client m, Prerender js t (Client m)) => Prerender js t m | m -> t js where
  -- | Monad in which the client widget is built
  type Client m :: * -> *
  -- | Render the first widget on the server, and the second on the client. The
  -- hydration builder will run *both* widgets, updating the result dynamic at
  -- switchover time.
  prerender :: m a -> Client m a -> m (Dynamic t a)

instance (ReflexHost t, Adjustable t m, PrerenderBaseConstraints js t m) => Prerender js t (HydrationDomBuilderT GhcjsDomSpace t m) where
  type Client (HydrationDomBuilderT GhcjsDomSpace t m) = HydrationDomBuilderT GhcjsDomSpace t m
  prerender :: HydrationDomBuilderT GhcjsDomSpace t m a
-> Client (HydrationDomBuilderT GhcjsDomSpace t m) a
-> HydrationDomBuilderT GhcjsDomSpace t m (Dynamic t a)
prerender HydrationDomBuilderT GhcjsDomSpace t m a
_ Client (HydrationDomBuilderT GhcjsDomSpace t m) a
client = a -> Dynamic t a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (a -> Dynamic t a)
-> HydrationDomBuilderT GhcjsDomSpace t m a
-> HydrationDomBuilderT GhcjsDomSpace t m (Dynamic t a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> HydrationDomBuilderT GhcjsDomSpace t m a
Client (HydrationDomBuilderT GhcjsDomSpace t m) a
client

instance (Adjustable t m, PrerenderBaseConstraints js t m, ReflexHost t) => Prerender js t (HydrationDomBuilderT HydrationDomSpace t m) where
  -- | PostBuildT is needed here because we delay running the client builder
  -- until after switchover, at which point the postBuild of @m@ has already fired
  type Client (HydrationDomBuilderT HydrationDomSpace t m) = PostBuildT t (HydrationDomBuilderT GhcjsDomSpace t m)
  -- | Runs the server widget up until switchover, then replaces it with the
  -- client widget.
  prerender :: HydrationDomBuilderT HydrationDomSpace t m a
-> Client (HydrationDomBuilderT HydrationDomSpace t m) a
-> HydrationDomBuilderT HydrationDomSpace t m (Dynamic t a)
prerender HydrationDomBuilderT HydrationDomSpace t m a
server Client (HydrationDomBuilderT HydrationDomSpace t m) a
client = do
    HydrationDomBuilderEnv t m
env <- ReaderT
  (HydrationDomBuilderEnv t m)
  (DomRenderHookT t m)
  (HydrationDomBuilderEnv t m)
-> HydrationDomBuilderT
     HydrationDomSpace t m (HydrationDomBuilderEnv t m)
forall k (s :: k) t (m :: * -> *) a.
ReaderT (HydrationDomBuilderEnv t m) (DomRenderHookT t m) a
-> HydrationDomBuilderT s t m a
HydrationDomBuilderT ReaderT
  (HydrationDomBuilderEnv t m)
  (DomRenderHookT t m)
  (HydrationDomBuilderEnv t m)
forall r (m :: * -> *). MonadReader r m => m r
ask
    Chan [DSum (EventTriggerRef t) TriggerInvocation]
events <- HydrationDomBuilderT
  HydrationDomSpace
  t
  m
  (Chan [DSum (EventTriggerRef t) TriggerInvocation])
forall k (m :: * -> *) (s :: k) t.
Monad m =>
HydrationDomBuilderT
  s t m (Chan [DSum (EventTriggerRef t) TriggerInvocation])
askEvents
    Document
doc <- HydrationDomBuilderT HydrationDomSpace t m Document
forall (m :: * -> *).
HasDocument m =>
m (RawDocument (DomBuilderSpace m))
askDocument
    DocumentFragment
serverDf <- Document
-> HydrationDomBuilderT HydrationDomSpace t m DocumentFragment
forall (m :: * -> *) self.
(MonadDOM m, IsDocument self) =>
self -> m DocumentFragment
Document.createDocumentFragment Document
doc -- server dom should not be mounted in the window's doc in hydration
    DocumentFragment
df <- Document
-> HydrationDomBuilderT HydrationDomSpace t m DocumentFragment
forall (m :: * -> *) self.
(MonadDOM m, IsDocument self) =>
self -> m DocumentFragment
Document.createDocumentFragment Document
doc
    IORef Word
unreadyChildren <- ReaderT
  (HydrationDomBuilderEnv t m) (DomRenderHookT t m) (IORef Word)
-> HydrationDomBuilderT HydrationDomSpace t m (IORef Word)
forall k (s :: k) t (m :: * -> *) a.
ReaderT (HydrationDomBuilderEnv t m) (DomRenderHookT t m) a
-> HydrationDomBuilderT s t m a
HydrationDomBuilderT (ReaderT
   (HydrationDomBuilderEnv t m) (DomRenderHookT t m) (IORef Word)
 -> HydrationDomBuilderT HydrationDomSpace t m (IORef Word))
-> ReaderT
     (HydrationDomBuilderEnv t m) (DomRenderHookT t m) (IORef Word)
-> HydrationDomBuilderT HydrationDomSpace t m (IORef Word)
forall a b. (a -> b) -> a -> b
$ (HydrationDomBuilderEnv t m -> IORef Word)
-> ReaderT
     (HydrationDomBuilderEnv t m) (DomRenderHookT t m) (IORef Word)
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks HydrationDomBuilderEnv t m -> IORef Word
forall t (m :: * -> *). HydrationDomBuilderEnv t m -> IORef Word
_hydrationDomBuilderEnv_unreadyChildren
    IORef HydrationMode
immediateMode <- IO (IORef HydrationMode)
-> HydrationDomBuilderT HydrationDomSpace t m (IORef HydrationMode)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (IORef HydrationMode)
 -> HydrationDomBuilderT
      HydrationDomSpace t m (IORef HydrationMode))
-> IO (IORef HydrationMode)
-> HydrationDomBuilderT HydrationDomSpace t m (IORef HydrationMode)
forall a b. (a -> b) -> a -> b
$ HydrationMode -> IO (IORef HydrationMode)
forall a. a -> IO (IORef a)
newIORef HydrationMode
HydrationMode_Immediate
    IORef (HydrationRunnerT t m ())
delayed <- IO (IORef (HydrationRunnerT t m ()))
-> HydrationDomBuilderT
     HydrationDomSpace t m (IORef (HydrationRunnerT t m ()))
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (IORef (HydrationRunnerT t m ()))
 -> HydrationDomBuilderT
      HydrationDomSpace t m (IORef (HydrationRunnerT t m ())))
-> IO (IORef (HydrationRunnerT t m ()))
-> HydrationDomBuilderT
     HydrationDomSpace t m (IORef (HydrationRunnerT t m ()))
forall a b. (a -> b) -> a -> b
$ HydrationRunnerT t m () -> IO (IORef (HydrationRunnerT t m ()))
forall a. a -> IO (IORef a)
newIORef (HydrationRunnerT t m () -> IO (IORef (HydrationRunnerT t m ())))
-> HydrationRunnerT t m () -> IO (IORef (HydrationRunnerT t m ()))
forall a b. (a -> b) -> a -> b
$ () -> HydrationRunnerT t m ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
    let clientEnv :: HydrationDomBuilderEnv t m
clientEnv = HydrationDomBuilderEnv t m
env
          { _hydrationDomBuilderEnv_parent :: Either Node (IORef Node)
_hydrationDomBuilderEnv_parent = Node -> Either Node (IORef Node)
forall a b. a -> Either a b
Left (Node -> Either Node (IORef Node))
-> Node -> Either Node (IORef Node)
forall a b. (a -> b) -> a -> b
$ DocumentFragment -> Node
forall o. IsNode o => o -> Node
DOM.toNode DocumentFragment
df
          , _hydrationDomBuilderEnv_hydrationMode :: IORef HydrationMode
_hydrationDomBuilderEnv_hydrationMode = IORef HydrationMode
immediateMode
          }
        serverEnv :: HydrationDomBuilderEnv t m
serverEnv = HydrationDomBuilderEnv :: forall t (m :: * -> *).
Document
-> Either Node (IORef Node)
-> IORef Word
-> JSM ()
-> IORef HydrationMode
-> Event t ()
-> IORef (HydrationRunnerT t m ())
-> HydrationDomBuilderEnv t m
HydrationDomBuilderEnv
          { _hydrationDomBuilderEnv_document :: Document
_hydrationDomBuilderEnv_document = Document
doc
          , _hydrationDomBuilderEnv_parent :: Either Node (IORef Node)
_hydrationDomBuilderEnv_parent = Node -> Either Node (IORef Node)
forall a b. a -> Either a b
Left (Node -> Either Node (IORef Node))
-> Node -> Either Node (IORef Node)
forall a b. (a -> b) -> a -> b
$ DocumentFragment -> Node
forall o. IsNode o => o -> Node
DOM.toNode DocumentFragment
serverDf
          , _hydrationDomBuilderEnv_unreadyChildren :: IORef Word
_hydrationDomBuilderEnv_unreadyChildren = IORef Word
unreadyChildren
          , _hydrationDomBuilderEnv_commitAction :: JSM ()
_hydrationDomBuilderEnv_commitAction = () -> JSM ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
          , _hydrationDomBuilderEnv_delayed :: IORef (HydrationRunnerT t m ())
_hydrationDomBuilderEnv_delayed = IORef (HydrationRunnerT t m ())
delayed
          , _hydrationDomBuilderEnv_hydrationMode :: IORef HydrationMode
_hydrationDomBuilderEnv_hydrationMode = IORef HydrationMode
immediateMode
          , _hydrationDomBuilderEnv_switchover :: Event t ()
_hydrationDomBuilderEnv_switchover = Event t ()
forall k (t :: k) a. Reflex t => Event t a
never
          }
    a
a0 <- m a -> HydrationDomBuilderT HydrationDomSpace t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> HydrationDomBuilderT HydrationDomSpace t m a)
-> m a -> HydrationDomBuilderT HydrationDomSpace t m a
forall a b. (a -> b) -> a -> b
$ HydrationDomBuilderT HydrationDomSpace t m a
-> HydrationDomBuilderEnv t m
-> Chan [DSum (EventTriggerRef t) TriggerInvocation]
-> m a
forall k (m :: * -> *) t (s :: k) a.
(MonadFix m, PerformEvent t m, MonadReflexCreateTrigger t m,
 MonadJSM m, MonadJSM (Performable m), MonadRef m, Ref m ~ IORef) =>
HydrationDomBuilderT s t m a
-> HydrationDomBuilderEnv t m
-> Chan [DSum (EventTriggerRef t) TriggerInvocation]
-> m a
runHydrationDomBuilderT HydrationDomBuilderT HydrationDomSpace t m a
server HydrationDomBuilderEnv t m
serverEnv Chan [DSum (EventTriggerRef t) TriggerInvocation]
events
    (Event t a
a', a -> IO ()
trigger) <- HydrationDomBuilderT HydrationDomSpace t m (Event t a, a -> IO ())
forall t (m :: * -> *) a.
TriggerEvent t m =>
m (Event t a, a -> IO ())
newTriggerEvent
    HydrationDomBuilderT HydrationDomSpace t m HydrationMode
forall k (m :: * -> *) (s :: k) t.
MonadIO m =>
HydrationDomBuilderT s t m HydrationMode
getHydrationMode HydrationDomBuilderT HydrationDomSpace t m HydrationMode
-> (HydrationMode -> HydrationDomBuilderT HydrationDomSpace t m ())
-> HydrationDomBuilderT HydrationDomSpace t m ()
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
      HydrationMode
HydrationMode_Immediate -> do
        IO () -> HydrationDomBuilderT HydrationDomSpace t m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> HydrationDomBuilderT HydrationDomSpace t m ())
-> (a -> IO ())
-> a
-> HydrationDomBuilderT HydrationDomSpace t m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> IO ()
trigger (a -> HydrationDomBuilderT HydrationDomSpace t m ())
-> (m a -> HydrationDomBuilderT HydrationDomSpace t m a)
-> m a
-> HydrationDomBuilderT HydrationDomSpace t m ()
forall (m :: * -> *) b c a.
Monad m =>
(b -> m c) -> (a -> m b) -> a -> m c
<=< m a -> HydrationDomBuilderT HydrationDomSpace t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> HydrationDomBuilderT HydrationDomSpace t m ())
-> m a -> HydrationDomBuilderT HydrationDomSpace t m ()
forall a b. (a -> b) -> a -> b
$ HydrationDomBuilderT GhcjsDomSpace t m a
-> HydrationDomBuilderEnv t m
-> Chan [DSum (EventTriggerRef t) TriggerInvocation]
-> m a
forall k (m :: * -> *) t (s :: k) a.
(MonadFix m, PerformEvent t m, MonadReflexCreateTrigger t m,
 MonadJSM m, MonadJSM (Performable m), MonadRef m, Ref m ~ IORef) =>
HydrationDomBuilderT s t m a
-> HydrationDomBuilderEnv t m
-> Chan [DSum (EventTriggerRef t) TriggerInvocation]
-> m a
runHydrationDomBuilderT (PostBuildT t (HydrationDomBuilderT GhcjsDomSpace t m) a
-> Event t () -> HydrationDomBuilderT GhcjsDomSpace t m a
forall t (m :: * -> *) a. PostBuildT t m a -> Event t () -> m a
runPostBuildT PostBuildT t (HydrationDomBuilderT GhcjsDomSpace t m) a
Client (HydrationDomBuilderT HydrationDomSpace t m) a
client (Event t () -> HydrationDomBuilderT GhcjsDomSpace t m a)
-> Event t () -> HydrationDomBuilderT GhcjsDomSpace t m a
forall a b. (a -> b) -> a -> b
$ Event t a -> Event t ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void Event t a
a') HydrationDomBuilderEnv t m
clientEnv Chan [DSum (EventTriggerRef t) TriggerInvocation]
events
        Node -> HydrationDomBuilderT HydrationDomSpace t m ()
forall k (m :: * -> *) (s :: k) t.
MonadJSM m =>
Node -> HydrationDomBuilderT s t m ()
append (Node -> HydrationDomBuilderT HydrationDomSpace t m ())
-> Node -> HydrationDomBuilderT HydrationDomSpace t m ()
forall a b. (a -> b) -> a -> b
$ DocumentFragment -> Node
forall o. IsNode o => o -> Node
DOM.toNode DocumentFragment
df
      HydrationMode
HydrationMode_Hydrating -> HydrationRunnerT t m ()
-> HydrationDomBuilderT HydrationDomSpace t m ()
forall k (m :: * -> *) t (s :: k).
MonadIO m =>
HydrationRunnerT t m () -> HydrationDomBuilderT s t m ()
addHydrationStep (HydrationRunnerT t m ()
 -> HydrationDomBuilderT HydrationDomSpace t m ())
-> HydrationRunnerT t m ()
-> HydrationDomBuilderT HydrationDomSpace t m ()
forall a b. (a -> b) -> a -> b
$ do
        IO () -> HydrationRunnerT t m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> HydrationRunnerT t m ())
-> (a -> IO ()) -> a -> HydrationRunnerT t m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> IO ()
trigger (a -> HydrationRunnerT t m ())
-> (m a -> HydrationRunnerT t m a)
-> m a
-> HydrationRunnerT t m ()
forall (m :: * -> *) b c a.
Monad m =>
(b -> m c) -> (a -> m b) -> a -> m c
<=< m a -> HydrationRunnerT t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> HydrationRunnerT t m ()) -> m a -> HydrationRunnerT t m ()
forall a b. (a -> b) -> a -> b
$ HydrationDomBuilderT GhcjsDomSpace t m a
-> HydrationDomBuilderEnv t m
-> Chan [DSum (EventTriggerRef t) TriggerInvocation]
-> m a
forall k (m :: * -> *) t (s :: k) a.
(MonadFix m, PerformEvent t m, MonadReflexCreateTrigger t m,
 MonadJSM m, MonadJSM (Performable m), MonadRef m, Ref m ~ IORef) =>
HydrationDomBuilderT s t m a
-> HydrationDomBuilderEnv t m
-> Chan [DSum (EventTriggerRef t) TriggerInvocation]
-> m a
runHydrationDomBuilderT (PostBuildT t (HydrationDomBuilderT GhcjsDomSpace t m) a
-> Event t () -> HydrationDomBuilderT GhcjsDomSpace t m a
forall t (m :: * -> *) a. PostBuildT t m a -> Event t () -> m a
runPostBuildT PostBuildT t (HydrationDomBuilderT GhcjsDomSpace t m) a
Client (HydrationDomBuilderT HydrationDomSpace t m) a
client (Event t () -> HydrationDomBuilderT GhcjsDomSpace t m a)
-> Event t () -> HydrationDomBuilderT GhcjsDomSpace t m a
forall a b. (a -> b) -> a -> b
$ Event t a -> Event t ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void Event t a
a') HydrationDomBuilderEnv t m
clientEnv Chan [DSum (EventTriggerRef t) TriggerInvocation]
events
        DocumentFragment -> Comment -> HydrationRunnerT t m ()
forall (m :: * -> *) new existing.
(MonadJSM m, IsNode new, IsNode existing) =>
new -> existing -> m ()
insertBefore DocumentFragment
df (Comment -> HydrationRunnerT t m ())
-> HydrationRunnerT t m Comment -> HydrationRunnerT t m ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Document -> HydrationRunnerT t m Comment
forall (m :: * -> *) t.
(MonadIO m, MonadJSM m, Reflex t, MonadFix m) =>
Document -> HydrationRunnerT t m Comment
deleteToPrerenderEnd Document
doc
    a
-> Event t a
-> HydrationDomBuilderT HydrationDomSpace t m (Dynamic t a)
forall k (t :: k) (m :: * -> *) a.
MonadHold t m =>
a -> Event t a -> m (Dynamic t a)
holdDyn a
a0 Event t a
a'

newtype UnrunnableT js t m a = UnrunnableT (ReaderT Void m a)
  deriving (a -> UnrunnableT js t m b -> UnrunnableT js t m a
(a -> b) -> UnrunnableT js t m a -> UnrunnableT js t m b
(forall a b.
 (a -> b) -> UnrunnableT js t m a -> UnrunnableT js t m b)
-> (forall a b. a -> UnrunnableT js t m b -> UnrunnableT js t m a)
-> Functor (UnrunnableT js t m)
forall a b. a -> UnrunnableT js t m b -> UnrunnableT js t m a
forall a b.
(a -> b) -> UnrunnableT js t m a -> UnrunnableT js t m b
forall js t (m :: * -> *) a b.
Functor m =>
a -> UnrunnableT js t m b -> UnrunnableT js t m a
forall js t (m :: * -> *) a b.
Functor m =>
(a -> b) -> UnrunnableT js t m a -> UnrunnableT js t m b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> UnrunnableT js t m b -> UnrunnableT js t m a
$c<$ :: forall js t (m :: * -> *) a b.
Functor m =>
a -> UnrunnableT js t m b -> UnrunnableT js t m a
fmap :: (a -> b) -> UnrunnableT js t m a -> UnrunnableT js t m b
$cfmap :: forall js t (m :: * -> *) a b.
Functor m =>
(a -> b) -> UnrunnableT js t m a -> UnrunnableT js t m b
Functor, Functor (UnrunnableT js t m)
a -> UnrunnableT js t m a
Functor (UnrunnableT js t m)
-> (forall a. a -> UnrunnableT js t m a)
-> (forall a b.
    UnrunnableT js t m (a -> b)
    -> UnrunnableT js t m a -> UnrunnableT js t m b)
-> (forall a b c.
    (a -> b -> c)
    -> UnrunnableT js t m a
    -> UnrunnableT js t m b
    -> UnrunnableT js t m c)
-> (forall a b.
    UnrunnableT js t m a
    -> UnrunnableT js t m b -> UnrunnableT js t m b)
-> (forall a b.
    UnrunnableT js t m a
    -> UnrunnableT js t m b -> UnrunnableT js t m a)
-> Applicative (UnrunnableT js t m)
UnrunnableT js t m a
-> UnrunnableT js t m b -> UnrunnableT js t m b
UnrunnableT js t m a
-> UnrunnableT js t m b -> UnrunnableT js t m a
UnrunnableT js t m (a -> b)
-> UnrunnableT js t m a -> UnrunnableT js t m b
(a -> b -> c)
-> UnrunnableT js t m a
-> UnrunnableT js t m b
-> UnrunnableT js t m c
forall a. a -> UnrunnableT js t m a
forall a b.
UnrunnableT js t m a
-> UnrunnableT js t m b -> UnrunnableT js t m a
forall a b.
UnrunnableT js t m a
-> UnrunnableT js t m b -> UnrunnableT js t m b
forall a b.
UnrunnableT js t m (a -> b)
-> UnrunnableT js t m a -> UnrunnableT js t m b
forall a b c.
(a -> b -> c)
-> UnrunnableT js t m a
-> UnrunnableT js t m b
-> UnrunnableT js t m c
forall js t (m :: * -> *).
Applicative m =>
Functor (UnrunnableT js t m)
forall js t (m :: * -> *) a.
Applicative m =>
a -> UnrunnableT js t m a
forall js t (m :: * -> *) a b.
Applicative m =>
UnrunnableT js t m a
-> UnrunnableT js t m b -> UnrunnableT js t m a
forall js t (m :: * -> *) a b.
Applicative m =>
UnrunnableT js t m a
-> UnrunnableT js t m b -> UnrunnableT js t m b
forall js t (m :: * -> *) a b.
Applicative m =>
UnrunnableT js t m (a -> b)
-> UnrunnableT js t m a -> UnrunnableT js t m b
forall js t (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c)
-> UnrunnableT js t m a
-> UnrunnableT js t m b
-> UnrunnableT js t m 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
<* :: UnrunnableT js t m a
-> UnrunnableT js t m b -> UnrunnableT js t m a
$c<* :: forall js t (m :: * -> *) a b.
Applicative m =>
UnrunnableT js t m a
-> UnrunnableT js t m b -> UnrunnableT js t m a
*> :: UnrunnableT js t m a
-> UnrunnableT js t m b -> UnrunnableT js t m b
$c*> :: forall js t (m :: * -> *) a b.
Applicative m =>
UnrunnableT js t m a
-> UnrunnableT js t m b -> UnrunnableT js t m b
liftA2 :: (a -> b -> c)
-> UnrunnableT js t m a
-> UnrunnableT js t m b
-> UnrunnableT js t m c
$cliftA2 :: forall js t (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c)
-> UnrunnableT js t m a
-> UnrunnableT js t m b
-> UnrunnableT js t m c
<*> :: UnrunnableT js t m (a -> b)
-> UnrunnableT js t m a -> UnrunnableT js t m b
$c<*> :: forall js t (m :: * -> *) a b.
Applicative m =>
UnrunnableT js t m (a -> b)
-> UnrunnableT js t m a -> UnrunnableT js t m b
pure :: a -> UnrunnableT js t m a
$cpure :: forall js t (m :: * -> *) a.
Applicative m =>
a -> UnrunnableT js t m a
$cp1Applicative :: forall js t (m :: * -> *).
Applicative m =>
Functor (UnrunnableT js t m)
Applicative, Applicative (UnrunnableT js t m)
a -> UnrunnableT js t m a
Applicative (UnrunnableT js t m)
-> (forall a b.
    UnrunnableT js t m a
    -> (a -> UnrunnableT js t m b) -> UnrunnableT js t m b)
-> (forall a b.
    UnrunnableT js t m a
    -> UnrunnableT js t m b -> UnrunnableT js t m b)
-> (forall a. a -> UnrunnableT js t m a)
-> Monad (UnrunnableT js t m)
UnrunnableT js t m a
-> (a -> UnrunnableT js t m b) -> UnrunnableT js t m b
UnrunnableT js t m a
-> UnrunnableT js t m b -> UnrunnableT js t m b
forall a. a -> UnrunnableT js t m a
forall a b.
UnrunnableT js t m a
-> UnrunnableT js t m b -> UnrunnableT js t m b
forall a b.
UnrunnableT js t m a
-> (a -> UnrunnableT js t m b) -> UnrunnableT js t m b
forall js t (m :: * -> *).
Monad m =>
Applicative (UnrunnableT js t m)
forall js t (m :: * -> *) a. Monad m => a -> UnrunnableT js t m a
forall js t (m :: * -> *) a b.
Monad m =>
UnrunnableT js t m a
-> UnrunnableT js t m b -> UnrunnableT js t m b
forall js t (m :: * -> *) a b.
Monad m =>
UnrunnableT js t m a
-> (a -> UnrunnableT js t m b) -> UnrunnableT js t m 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
return :: a -> UnrunnableT js t m a
$creturn :: forall js t (m :: * -> *) a. Monad m => a -> UnrunnableT js t m a
>> :: UnrunnableT js t m a
-> UnrunnableT js t m b -> UnrunnableT js t m b
$c>> :: forall js t (m :: * -> *) a b.
Monad m =>
UnrunnableT js t m a
-> UnrunnableT js t m b -> UnrunnableT js t m b
>>= :: UnrunnableT js t m a
-> (a -> UnrunnableT js t m b) -> UnrunnableT js t m b
$c>>= :: forall js t (m :: * -> *) a b.
Monad m =>
UnrunnableT js t m a
-> (a -> UnrunnableT js t m b) -> UnrunnableT js t m b
$cp1Monad :: forall js t (m :: * -> *).
Monad m =>
Applicative (UnrunnableT js t m)
Monad, m a -> UnrunnableT js t m a
(forall (m :: * -> *) a. Monad m => m a -> UnrunnableT js t m a)
-> MonadTrans (UnrunnableT js t)
forall js t (m :: * -> *) a. Monad m => m a -> UnrunnableT js t m a
forall (m :: * -> *) a. Monad m => m a -> UnrunnableT js t m a
forall (t :: (* -> *) -> * -> *).
(forall (m :: * -> *) a. Monad m => m a -> t m a) -> MonadTrans t
lift :: m a -> UnrunnableT js t m a
$clift :: forall js t (m :: * -> *) a. Monad m => m a -> UnrunnableT js t m a
MonadTrans)

unrunnable :: UnrunnableT js t m a
unrunnable :: UnrunnableT js t m a
unrunnable = ReaderT Void m a -> UnrunnableT js t m a
forall js t (m :: * -> *) a.
ReaderT Void m a -> UnrunnableT js t m a
UnrunnableT (ReaderT Void m a -> UnrunnableT js t m a)
-> ReaderT Void m a -> UnrunnableT js t m a
forall a b. (a -> b) -> a -> b
$ (Void -> m a) -> ReaderT Void m a
forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
ReaderT ((Void -> m a) -> ReaderT Void m a)
-> (Void -> m a) -> ReaderT Void m a
forall a b. (a -> b) -> a -> b
$ \case {}

instance (Reflex t, Monad m) => DomBuilder t (UnrunnableT js t m) where
  type DomBuilderSpace (UnrunnableT js t m) = GhcjsDomSpace
  textNode :: TextNodeConfig t
-> UnrunnableT
     js t m (TextNode (DomBuilderSpace (UnrunnableT js t m)) t)
textNode TextNodeConfig t
_ = UnrunnableT
  js t m (TextNode (DomBuilderSpace (UnrunnableT js t m)) t)
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  commentNode :: CommentNodeConfig t
-> UnrunnableT
     js t m (CommentNode (DomBuilderSpace (UnrunnableT js t m)) t)
commentNode CommentNodeConfig t
_ = UnrunnableT
  js t m (CommentNode (DomBuilderSpace (UnrunnableT js t m)) t)
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  element :: Text
-> ElementConfig er t (DomBuilderSpace (UnrunnableT js t m))
-> UnrunnableT js t m a
-> UnrunnableT
     js t m (Element er (DomBuilderSpace (UnrunnableT js t m)) t, a)
element Text
_ ElementConfig er t (DomBuilderSpace (UnrunnableT js t m))
_ UnrunnableT js t m a
_ = UnrunnableT
  js t m (Element er (DomBuilderSpace (UnrunnableT js t m)) t, a)
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  inputElement :: InputElementConfig er t (DomBuilderSpace (UnrunnableT js t m))
-> UnrunnableT
     js t m (InputElement er (DomBuilderSpace (UnrunnableT js t m)) t)
inputElement InputElementConfig er t (DomBuilderSpace (UnrunnableT js t m))
_ = UnrunnableT
  js t m (InputElement er (DomBuilderSpace (UnrunnableT js t m)) t)
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  textAreaElement :: TextAreaElementConfig er t (DomBuilderSpace (UnrunnableT js t m))
-> UnrunnableT
     js
     t
     m
     (TextAreaElement er (DomBuilderSpace (UnrunnableT js t m)) t)
textAreaElement TextAreaElementConfig er t (DomBuilderSpace (UnrunnableT js t m))
_ = UnrunnableT
  js
  t
  m
  (TextAreaElement er (DomBuilderSpace (UnrunnableT js t m)) t)
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  selectElement :: SelectElementConfig er t (DomBuilderSpace (UnrunnableT js t m))
-> UnrunnableT js t m a
-> UnrunnableT
     js
     t
     m
     (SelectElement er (DomBuilderSpace (UnrunnableT js t m)) t, a)
selectElement SelectElementConfig er t (DomBuilderSpace (UnrunnableT js t m))
_ UnrunnableT js t m a
_ = UnrunnableT
  js
  t
  m
  (SelectElement er (DomBuilderSpace (UnrunnableT js t m)) t, a)
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  placeRawElement :: RawElement (DomBuilderSpace (UnrunnableT js t m))
-> UnrunnableT js t m ()
placeRawElement RawElement (DomBuilderSpace (UnrunnableT js t m))
_ = UnrunnableT js t m ()
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  wrapRawElement :: RawElement (DomBuilderSpace (UnrunnableT js t m))
-> RawElementConfig er t (DomBuilderSpace (UnrunnableT js t m))
-> UnrunnableT
     js t m (Element er (DomBuilderSpace (UnrunnableT js t m)) t)
wrapRawElement RawElement (DomBuilderSpace (UnrunnableT js t m))
_ RawElementConfig er t (DomBuilderSpace (UnrunnableT js t m))
_ = UnrunnableT
  js t m (Element er (DomBuilderSpace (UnrunnableT js t m)) t)
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
instance (Reflex t, Monad m) => NotReady t (UnrunnableT js t m) where
  notReadyUntil :: Event t a -> UnrunnableT js t m ()
notReadyUntil Event t a
_ = UnrunnableT js t m ()
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  notReady :: UnrunnableT js t m ()
notReady = UnrunnableT js t m ()
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
instance (Reflex t, Monad m) => Adjustable t (UnrunnableT js t m) where
  runWithReplace :: UnrunnableT js t m a
-> Event t (UnrunnableT js t m b)
-> UnrunnableT js t m (a, Event t b)
runWithReplace UnrunnableT js t m a
_ Event t (UnrunnableT js t m b)
_ = UnrunnableT js t m (a, Event t b)
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  traverseIntMapWithKeyWithAdjust :: (Key -> v -> UnrunnableT js t m v')
-> IntMap v
-> Event t (PatchIntMap v)
-> UnrunnableT js t m (IntMap v', Event t (PatchIntMap v'))
traverseIntMapWithKeyWithAdjust Key -> v -> UnrunnableT js t m v'
_ IntMap v
_ Event t (PatchIntMap v)
_ = UnrunnableT js t m (IntMap v', Event t (PatchIntMap v'))
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  traverseDMapWithKeyWithAdjust :: (forall a. k a -> v a -> UnrunnableT js t m (v' a))
-> DMap k v
-> Event t (PatchDMap k v)
-> UnrunnableT js t m (DMap k v', Event t (PatchDMap k v'))
traverseDMapWithKeyWithAdjust forall a. k a -> v a -> UnrunnableT js t m (v' a)
_ DMap k v
_ Event t (PatchDMap k v)
_ = UnrunnableT js t m (DMap k v', Event t (PatchDMap k v'))
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  traverseDMapWithKeyWithAdjustWithMove :: (forall a. k a -> v a -> UnrunnableT js t m (v' a))
-> DMap k v
-> Event t (PatchDMapWithMove k v)
-> UnrunnableT js t m (DMap k v', Event t (PatchDMapWithMove k v'))
traverseDMapWithKeyWithAdjustWithMove forall a. k a -> v a -> UnrunnableT js t m (v' a)
_ DMap k v
_ Event t (PatchDMapWithMove k v)
_ = UnrunnableT js t m (DMap k v', Event t (PatchDMapWithMove k v'))
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
instance (Reflex t, Monad m) => PerformEvent t (UnrunnableT js t m) where
  type Performable (UnrunnableT js t m) = UnrunnableT js t m
  performEvent :: Event t (Performable (UnrunnableT js t m) a)
-> UnrunnableT js t m (Event t a)
performEvent Event t (Performable (UnrunnableT js t m) a)
_ = UnrunnableT js t m (Event t a)
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  performEvent_ :: Event t (Performable (UnrunnableT js t m) ())
-> UnrunnableT js t m ()
performEvent_ Event t (Performable (UnrunnableT js t m) ())
_ = UnrunnableT js t m ()
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
instance Monad m => MonadRef (UnrunnableT js t m) where
  type Ref (UnrunnableT js t m) = Ref IO
  newRef :: a -> UnrunnableT js t m (Ref (UnrunnableT js t m) a)
newRef a
_ = UnrunnableT js t m (Ref (UnrunnableT js t m) a)
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  readRef :: Ref (UnrunnableT js t m) a -> UnrunnableT js t m a
readRef Ref (UnrunnableT js t m) a
_ = UnrunnableT js t m a
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  writeRef :: Ref (UnrunnableT js t m) a -> a -> UnrunnableT js t m ()
writeRef Ref (UnrunnableT js t m) a
_ a
_ = UnrunnableT js t m ()
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
instance Monad m => MonadAtomicRef (UnrunnableT js t m) where
  atomicModifyRef :: Ref (UnrunnableT js t m) a -> (a -> (a, b)) -> UnrunnableT js t m b
atomicModifyRef Ref (UnrunnableT js t m) a
_ a -> (a, b)
_ = UnrunnableT js t m b
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
instance Monad m => HasDocument (UnrunnableT js t m) where
  askDocument :: UnrunnableT
  js t m (RawDocument (DomBuilderSpace (UnrunnableT js t m)))
askDocument = UnrunnableT
  js t m (RawDocument (DomBuilderSpace (UnrunnableT js t m)))
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
instance Monad m => HasJSContext (UnrunnableT js t m) where
  type JSContextPhantom (UnrunnableT js t m) = ()
  askJSContext :: UnrunnableT
  js t m (JSContextSingleton (JSContextPhantom (UnrunnableT js t m)))
askJSContext = UnrunnableT
  js t m (JSContextSingleton (JSContextPhantom (UnrunnableT js t m)))
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
instance Monad m => HasJS JS' (UnrunnableT js t m) where
  type JSX (UnrunnableT js t m) = UnrunnableT js t m
  liftJS :: JSX (UnrunnableT js t m) a -> UnrunnableT js t m a
liftJS JSX (UnrunnableT js t m) a
_ = UnrunnableT js t m a
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
instance Monad m => MonadJS JS' (UnrunnableT js t m) where
  runJS :: JSFFI -> [JSRef JS'] -> UnrunnableT js t m (JSRef JS')
runJS JSFFI
_ [JSRef JS']
_ = UnrunnableT js t m (JSRef JS')
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  forkJS :: UnrunnableT js t m () -> UnrunnableT js t m ThreadId
forkJS UnrunnableT js t m ()
_ = UnrunnableT js t m ThreadId
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  mkJSUndefined :: UnrunnableT js t m (JSRef JS')
mkJSUndefined = UnrunnableT js t m (JSRef JS')
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  isJSNull :: JSRef JS' -> UnrunnableT js t m Bool
isJSNull JSRef JS'
_ = UnrunnableT js t m Bool
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  isJSUndefined :: JSRef JS' -> UnrunnableT js t m Bool
isJSUndefined JSRef JS'
_ = UnrunnableT js t m Bool
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  fromJSBool :: JSRef JS' -> UnrunnableT js t m Bool
fromJSBool JSRef JS'
_ = UnrunnableT js t m Bool
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  fromJSString :: JSRef JS' -> UnrunnableT js t m String
fromJSString JSRef JS'
_ = UnrunnableT js t m String
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  fromJSArray :: JSRef JS' -> UnrunnableT js t m [JSRef JS']
fromJSArray JSRef JS'
_ = UnrunnableT js t m [JSRef JS']
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  fromJSUint8Array :: JSRef JS' -> UnrunnableT js t m ByteString
fromJSUint8Array JSRef JS'
_ = UnrunnableT js t m ByteString
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  fromJSNumber :: JSRef JS' -> UnrunnableT js t m Double
fromJSNumber JSRef JS'
_ = UnrunnableT js t m Double
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  withJSBool :: Bool -> (JSRef JS' -> UnrunnableT js t m r) -> UnrunnableT js t m r
withJSBool Bool
_ JSRef JS' -> UnrunnableT js t m r
_ = UnrunnableT js t m r
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  withJSString :: String
-> (JSRef JS' -> UnrunnableT js t m r) -> UnrunnableT js t m r
withJSString String
_ JSRef JS' -> UnrunnableT js t m r
_ = UnrunnableT js t m r
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  withJSNumber :: Double
-> (JSRef JS' -> UnrunnableT js t m r) -> UnrunnableT js t m r
withJSNumber Double
_ JSRef JS' -> UnrunnableT js t m r
_ = UnrunnableT js t m r
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  withJSArray :: [JSRef JS']
-> (JSRef JS' -> UnrunnableT js t m r) -> UnrunnableT js t m r
withJSArray [JSRef JS']
_ JSRef JS' -> UnrunnableT js t m r
_ = UnrunnableT js t m r
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  withJSUint8Array :: ByteString
-> (JSUint8Array JS' -> UnrunnableT js t m r)
-> UnrunnableT js t m r
withJSUint8Array ByteString
_ JSUint8Array JS' -> UnrunnableT js t m r
_ = UnrunnableT js t m r
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  mkJSFun :: ([JSRef JS'] -> UnrunnableT js t m (JSRef JS'))
-> UnrunnableT js t m (JSFun JS')
mkJSFun [JSRef JS'] -> UnrunnableT js t m (JSRef JS')
_ = UnrunnableT js t m (JSFun JS')
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  freeJSFun :: JSFun JS' -> UnrunnableT js t m ()
freeJSFun JSFun JS'
_ = UnrunnableT js t m ()
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  setJSProp :: String -> JSRef JS' -> JSRef JS' -> UnrunnableT js t m ()
setJSProp String
_ JSRef JS'
_ JSRef JS'
_ = UnrunnableT js t m ()
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  getJSProp :: String -> JSRef JS' -> UnrunnableT js t m (JSRef JS')
getJSProp String
_ JSRef JS'
_ = UnrunnableT js t m (JSRef JS')
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  withJSNode :: Node -> (JSRef JS' -> UnrunnableT js t m r) -> UnrunnableT js t m r
withJSNode Node
_ JSRef JS' -> UnrunnableT js t m r
_ = UnrunnableT js t m r
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
instance Monad m => TriggerEvent t (UnrunnableT js t m) where
  newTriggerEvent :: UnrunnableT js t m (Event t a, a -> IO ())
newTriggerEvent = UnrunnableT js t m (Event t a, a -> IO ())
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  newTriggerEventWithOnComplete :: UnrunnableT js t m (Event t a, a -> IO () -> IO ())
newTriggerEventWithOnComplete = UnrunnableT js t m (Event t a, a -> IO () -> IO ())
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  newEventWithLazyTriggerWithOnComplete :: ((a -> IO () -> IO ()) -> IO (IO ()))
-> UnrunnableT js t m (Event t a)
newEventWithLazyTriggerWithOnComplete (a -> IO () -> IO ()) -> IO (IO ())
_ = UnrunnableT js t m (Event t a)
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
instance Monad m => MonadReflexCreateTrigger t (UnrunnableT js t m) where
  newEventWithTrigger :: (EventTrigger t a -> IO (IO ())) -> UnrunnableT js t m (Event t a)
newEventWithTrigger EventTrigger t a -> IO (IO ())
_ = UnrunnableT js t m (Event t a)
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  newFanEventWithTrigger :: (forall a. k a -> EventTrigger t a -> IO (IO ()))
-> UnrunnableT js t m (EventSelector t k)
newFanEventWithTrigger forall a. k a -> EventTrigger t a -> IO (IO ())
_ = UnrunnableT js t m (EventSelector t k)
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
instance Monad m => MonadFix (UnrunnableT js t m) where
  mfix :: (a -> UnrunnableT js t m a) -> UnrunnableT js t m a
mfix a -> UnrunnableT js t m a
_ = UnrunnableT js t m a
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
instance (Monad m, MonadHold t m) => MonadHold t (UnrunnableT js t m) where
  hold :: a -> Event t a -> UnrunnableT js t m (Behavior t a)
hold a
_ Event t a
_ = UnrunnableT js t m (Behavior t a)
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  holdDyn :: a -> Event t a -> UnrunnableT js t m (Dynamic t a)
holdDyn a
_ Event t a
_ = UnrunnableT js t m (Dynamic t a)
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  holdIncremental :: PatchTarget p -> Event t p -> UnrunnableT js t m (Incremental t p)
holdIncremental PatchTarget p
_ Event t p
_ = UnrunnableT js t m (Incremental t p)
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  buildDynamic :: PushM t a -> Event t a -> UnrunnableT js t m (Dynamic t a)
buildDynamic PushM t a
_ Event t a
_ = UnrunnableT js t m (Dynamic t a)
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  headE :: Event t a -> UnrunnableT js t m (Event t a)
headE Event t a
_ = UnrunnableT js t m (Event t a)
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  now :: UnrunnableT js t m (Event t ())
now = UnrunnableT js t m (Event t ())
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
instance Monad m => MonadSample t (UnrunnableT js t m) where
  sample :: Behavior t a -> UnrunnableT js t m a
sample Behavior t a
_ = UnrunnableT js t m a
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
instance Monad m => MonadIO (UnrunnableT js t m) where
  liftIO :: IO a -> UnrunnableT js t m a
liftIO IO a
_ = UnrunnableT js t m a
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
#ifndef ghcjs_HOST_OS
instance Monad m => MonadJSM (UnrunnableT js t m) where
  liftJSM' :: JSM a -> UnrunnableT js t m a
liftJSM' JSM a
_ = UnrunnableT js t m a
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
#endif
instance (Reflex t, Monad m) => PostBuild t (UnrunnableT js t m) where
  getPostBuild :: UnrunnableT js t m (Event t ())
getPostBuild = UnrunnableT js t m (Event t ())
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
instance Monad m => PrimMonad (UnrunnableT js t m) where
  type PrimState (UnrunnableT js t m) = PrimState IO
  primitive :: (State# (PrimState (UnrunnableT js t m))
 -> (# State# (PrimState (UnrunnableT js t m)), a #))
-> UnrunnableT js t m a
primitive State# (PrimState (UnrunnableT js t m))
-> (# State# (PrimState (UnrunnableT js t m)), a #)
_ = UnrunnableT js t m a
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
instance (Reflex t, Monad m) => DomRenderHook t (UnrunnableT js t m) where
  withRenderHook :: (forall x. JSM x -> JSM x)
-> UnrunnableT js t m a -> UnrunnableT js t m a
withRenderHook forall x. JSM x -> JSM x
_ UnrunnableT js t m a
_ = UnrunnableT js t m a
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  requestDomAction :: Event t (JSM a) -> UnrunnableT js t m (Event t a)
requestDomAction Event t (JSM a)
_ = UnrunnableT js t m (Event t a)
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
  requestDomAction_ :: Event t (JSM a) -> UnrunnableT js t m ()
requestDomAction_ Event t (JSM a)
_ = UnrunnableT js t m ()
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable
instance (Reflex t, Monad m, MonadHold t m) => Prerender JS' t (UnrunnableT js t m) where
  type Client (UnrunnableT js t m) = UnrunnableT js t m
  prerender :: UnrunnableT js t m a
-> Client (UnrunnableT js t m) a
-> UnrunnableT js t m (Dynamic t a)
prerender UnrunnableT js t m a
_ Client (UnrunnableT js t m) a
_ = UnrunnableT js t m (Dynamic t a)
forall js t (m :: * -> *) a. UnrunnableT js t m a
unrunnable

instance (SupportsStaticDomBuilder t m) => Prerender JS' t (StaticDomBuilderT t m) where
  type Client (StaticDomBuilderT t m) = UnrunnableT JS' t m
  prerender :: StaticDomBuilderT t m a
-> Client (StaticDomBuilderT t m) a
-> StaticDomBuilderT t m (Dynamic t a)
prerender StaticDomBuilderT t m a
server Client (StaticDomBuilderT t m) a
_ = do
    CommentNode StaticDomSpace t
_ <- CommentNodeConfig t
-> StaticDomBuilderT
     t m (CommentNode (DomBuilderSpace (StaticDomBuilderT t m)) t)
forall t (m :: * -> *).
DomBuilder t m =>
CommentNodeConfig t -> m (CommentNode (DomBuilderSpace m) t)
commentNode (CommentNodeConfig t
 -> StaticDomBuilderT
      t m (CommentNode (DomBuilderSpace (StaticDomBuilderT t m)) t))
-> CommentNodeConfig t
-> StaticDomBuilderT
     t m (CommentNode (DomBuilderSpace (StaticDomBuilderT t m)) t)
forall a b. (a -> b) -> a -> b
$ Text -> Maybe (Event t Text) -> CommentNodeConfig t
forall k (t :: k).
Text -> Maybe (Event t Text) -> CommentNodeConfig t
CommentNodeConfig Text
startMarker Maybe (Event t Text)
forall a. Maybe a
Nothing
    a
a <- StaticDomBuilderT t m a
server
    CommentNode StaticDomSpace t
_ <- CommentNodeConfig t
-> StaticDomBuilderT
     t m (CommentNode (DomBuilderSpace (StaticDomBuilderT t m)) t)
forall t (m :: * -> *).
DomBuilder t m =>
CommentNodeConfig t -> m (CommentNode (DomBuilderSpace m) t)
commentNode (CommentNodeConfig t
 -> StaticDomBuilderT
      t m (CommentNode (DomBuilderSpace (StaticDomBuilderT t m)) t))
-> CommentNodeConfig t
-> StaticDomBuilderT
     t m (CommentNode (DomBuilderSpace (StaticDomBuilderT t m)) t)
forall a b. (a -> b) -> a -> b
$ Text -> Maybe (Event t Text) -> CommentNodeConfig t
forall k (t :: k).
Text -> Maybe (Event t Text) -> CommentNodeConfig t
CommentNodeConfig Text
endMarker Maybe (Event t Text)
forall a. Maybe a
Nothing
    Dynamic t a -> StaticDomBuilderT t m (Dynamic t a)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Dynamic t a -> StaticDomBuilderT t m (Dynamic t a))
-> Dynamic t a -> StaticDomBuilderT t m (Dynamic t a)
forall a b. (a -> b) -> a -> b
$ a -> Dynamic t a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a
a

instance (Prerender js t m, Monad m) => Prerender js t (ReaderT r m) where
  type Client (ReaderT r m) = ReaderT r (Client m)
  prerender :: ReaderT r m a
-> Client (ReaderT r m) a -> ReaderT r m (Dynamic t a)
prerender ReaderT r m a
server Client (ReaderT r m) a
client = do
    r
r <- ReaderT r m r
forall r (m :: * -> *). MonadReader r m => m r
ask
    m (Dynamic t a) -> ReaderT r m (Dynamic t a)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Dynamic t a) -> ReaderT r m (Dynamic t a))
-> m (Dynamic t a) -> ReaderT r m (Dynamic t a)
forall a b. (a -> b) -> a -> b
$ m a -> Client m a -> m (Dynamic t a)
forall js t (m :: * -> *) a.
Prerender js t m =>
m a -> Client m a -> m (Dynamic t a)
prerender (ReaderT r m a -> r -> m a
forall r (m :: * -> *) a. ReaderT r m a -> r -> m a
runReaderT ReaderT r m a
server r
r) (ReaderT r (Client m) a -> r -> Client m a
forall r (m :: * -> *) a. ReaderT r m a -> r -> m a
runReaderT ReaderT r (Client m) a
Client (ReaderT r m) a
client r
r)

instance (Prerender js t m, Monad m, Reflex t, MonadFix m, Monoid w) => Prerender js t (DynamicWriterT t w m) where
  type Client (DynamicWriterT t w m) = DynamicWriterT t w (Client m)
  prerender :: DynamicWriterT t w m a
-> Client (DynamicWriterT t w m) a
-> DynamicWriterT t w m (Dynamic t a)
prerender DynamicWriterT t w m a
server Client (DynamicWriterT t w m) a
client = do
    Dynamic t (a, Dynamic t w)
x <- m (Dynamic t (a, Dynamic t w))
-> DynamicWriterT t w m (Dynamic t (a, Dynamic t w))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Dynamic t (a, Dynamic t w))
 -> DynamicWriterT t w m (Dynamic t (a, Dynamic t w)))
-> m (Dynamic t (a, Dynamic t w))
-> DynamicWriterT t w m (Dynamic t (a, Dynamic t w))
forall a b. (a -> b) -> a -> b
$ m (a, Dynamic t w)
-> Client m (a, Dynamic t w) -> m (Dynamic t (a, Dynamic t w))
forall js t (m :: * -> *) a.
Prerender js t m =>
m a -> Client m a -> m (Dynamic t a)
prerender (DynamicWriterT t w m a -> m (a, Dynamic t w)
forall (m :: * -> *) t w a.
(MonadFix m, Reflex t, Monoid w) =>
DynamicWriterT t w m a -> m (a, Dynamic t w)
runDynamicWriterT DynamicWriterT t w m a
server) (DynamicWriterT t w (Client m) a -> Client m (a, Dynamic t w)
forall (m :: * -> *) t w a.
(MonadFix m, Reflex t, Monoid w) =>
DynamicWriterT t w m a -> m (a, Dynamic t w)
runDynamicWriterT DynamicWriterT t w (Client m) a
Client (DynamicWriterT t w m) a
client)
    let (Dynamic t a
a, Dynamic t (Dynamic t w)
w') = Dynamic t (a, Dynamic t w)
-> (Dynamic t a, Dynamic t (Dynamic t w))
forall k (t :: k) a b.
Reflex t =>
Dynamic t (a, b) -> (Dynamic t a, Dynamic t b)
splitDynPure Dynamic t (a, Dynamic t w)
x
        w :: Dynamic t w
w = Dynamic t (Dynamic t w) -> Dynamic t w
forall (m :: * -> *) a. Monad m => m (m a) -> m a
join Dynamic t (Dynamic t w)
w'
    Dynamic t w -> DynamicWriterT t w m ()
forall t w (m :: * -> *).
DynamicWriter t w m =>
Dynamic t w -> m ()
tellDyn Dynamic t w
w
    Dynamic t a -> DynamicWriterT t w m (Dynamic t a)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Dynamic t a
a

instance (Prerender js t m, Monad m, Reflex t, Semigroup w) => Prerender js t (EventWriterT t w m) where
  type Client (EventWriterT t w m) = EventWriterT t w (Client m)
  prerender :: EventWriterT t w m a
-> Client (EventWriterT t w m) a
-> EventWriterT t w m (Dynamic t a)
prerender EventWriterT t w m a
server Client (EventWriterT t w m) a
client = do
    Dynamic t (a, Event t w)
x <- m (Dynamic t (a, Event t w))
-> EventWriterT t w m (Dynamic t (a, Event t w))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Dynamic t (a, Event t w))
 -> EventWriterT t w m (Dynamic t (a, Event t w)))
-> m (Dynamic t (a, Event t w))
-> EventWriterT t w m (Dynamic t (a, Event t w))
forall a b. (a -> b) -> a -> b
$ m (a, Event t w)
-> Client m (a, Event t w) -> m (Dynamic t (a, Event t w))
forall js t (m :: * -> *) a.
Prerender js t m =>
m a -> Client m a -> m (Dynamic t a)
prerender (EventWriterT t w m a -> m (a, Event t w)
forall t (m :: * -> *) w a.
(Reflex t, Monad m, Semigroup w) =>
EventWriterT t w m a -> m (a, Event t w)
runEventWriterT EventWriterT t w m a
server) (EventWriterT t w (Client m) a -> Client m (a, Event t w)
forall t (m :: * -> *) w a.
(Reflex t, Monad m, Semigroup w) =>
EventWriterT t w m a -> m (a, Event t w)
runEventWriterT EventWriterT t w (Client m) a
Client (EventWriterT t w m) a
client)
    let (Dynamic t a
a, Dynamic t (Event t w)
w') = Dynamic t (a, Event t w) -> (Dynamic t a, Dynamic t (Event t w))
forall k (t :: k) a b.
Reflex t =>
Dynamic t (a, b) -> (Dynamic t a, Dynamic t b)
splitDynPure Dynamic t (a, Event t w)
x
        w :: Event t w
w = Behavior t (Event t w) -> Event t w
forall k (t :: k) a.
Reflex t =>
Behavior t (Event t a) -> Event t a
switch (Behavior t (Event t w) -> Event t w)
-> Behavior t (Event t w) -> Event t w
forall a b. (a -> b) -> a -> b
$ Dynamic t (Event t w) -> Behavior t (Event t w)
forall k (t :: k) a. Reflex t => Dynamic t a -> Behavior t a
current Dynamic t (Event t w)
w'
    Event t w -> EventWriterT t w m ()
forall t w (m :: * -> *). EventWriter t w m => Event t w -> m ()
tellEvent Event t w
w
    Dynamic t a -> EventWriterT t w m (Dynamic t a)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Dynamic t a
a

instance (Prerender js t m, MonadFix m, Reflex t) => Prerender js t (RequesterT t request response m) where
  type Client (RequesterT t request response m) = RequesterT t request response (Client m)
  prerender :: RequesterT t request response m a
-> Client (RequesterT t request response m) a
-> RequesterT t request response m (Dynamic t a)
prerender RequesterT t request response m a
server Client (RequesterT t request response m) a
client = mdo
    let fannedResponses :: EventSelectorInt t (RequesterData response)
fannedResponses = Event t (IntMap (RequesterData response))
-> EventSelectorInt t (RequesterData response)
forall k (t :: k) a.
Reflex t =>
Event t (IntMap a) -> EventSelectorInt t a
fanInt Event t (IntMap (RequesterData response))
responses
        withFannedResponses :: forall m' a. Monad m' => RequesterT t request response m' a -> Int -> m' (a, Event t (IntMap (RequesterData request)))
        withFannedResponses :: RequesterT t request response m' a
-> Key -> m' (a, Event t (IntMap (RequesterData request)))
withFannedResponses RequesterT t request response m' a
w Key
selector = do
          (a
x, Event t (RequesterData request)
e) <- RequesterT t request response m' a
-> Event t (RequesterData response)
-> m' (a, Event t (RequesterData request))
forall t (m :: * -> *) (request :: * -> *) (response :: * -> *) a.
(Reflex t, Monad m) =>
RequesterT t request response m a
-> Event t (RequesterData response)
-> m (a, Event t (RequesterData request))
runRequesterT RequesterT t request response m' a
w (EventSelectorInt t (RequesterData response)
-> Key -> Event t (RequesterData response)
forall k (t :: k) a. EventSelectorInt t a -> Key -> Event t a
selectInt EventSelectorInt t (RequesterData response)
fannedResponses Key
selector)
          (a, Event t (IntMap (RequesterData request)))
-> m' (a, Event t (IntMap (RequesterData request)))
forall (f :: * -> *) a. Applicative f => a -> f a
pure (a
x, (RequesterData request -> IntMap (RequesterData request))
-> Event t (RequesterData request)
-> Event t (IntMap (RequesterData request))
forall k (t :: k) a b.
Reflex t =>
(a -> b) -> Event t a -> Event t b
fmapCheap (Key -> RequesterData request -> IntMap (RequesterData request)
forall a. Key -> a -> IntMap a
IntMap.singleton Key
selector) Event t (RequesterData request)
e)
    (Dynamic t a
result, Dynamic t (Event t (IntMap (RequesterData request)))
requestsDyn) <- (Dynamic t (a, Event t (IntMap (RequesterData request)))
 -> (Dynamic t a,
     Dynamic t (Event t (IntMap (RequesterData request)))))
-> RequesterT
     t
     request
     response
     m
     (Dynamic t (a, Event t (IntMap (RequesterData request))))
-> RequesterT
     t
     request
     response
     m
     (Dynamic t a, Dynamic t (Event t (IntMap (RequesterData request))))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Dynamic t (a, Event t (IntMap (RequesterData request)))
-> (Dynamic t a,
    Dynamic t (Event t (IntMap (RequesterData request))))
forall k (t :: k) a b.
Reflex t =>
Dynamic t (a, b) -> (Dynamic t a, Dynamic t b)
splitDynPure (RequesterT
   t
   request
   response
   m
   (Dynamic t (a, Event t (IntMap (RequesterData request))))
 -> RequesterT
      t
      request
      response
      m
      (Dynamic t a,
       Dynamic t (Event t (IntMap (RequesterData request)))))
-> RequesterT
     t
     request
     response
     m
     (Dynamic t (a, Event t (IntMap (RequesterData request))))
-> RequesterT
     t
     request
     response
     m
     (Dynamic t a, Dynamic t (Event t (IntMap (RequesterData request))))
forall a b. (a -> b) -> a -> b
$ m (Dynamic t (a, Event t (IntMap (RequesterData request))))
-> RequesterT
     t
     request
     response
     m
     (Dynamic t (a, Event t (IntMap (RequesterData request))))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Dynamic t (a, Event t (IntMap (RequesterData request))))
 -> RequesterT
      t
      request
      response
      m
      (Dynamic t (a, Event t (IntMap (RequesterData request)))))
-> m (Dynamic t (a, Event t (IntMap (RequesterData request))))
-> RequesterT
     t
     request
     response
     m
     (Dynamic t (a, Event t (IntMap (RequesterData request))))
forall a b. (a -> b) -> a -> b
$ m (a, Event t (IntMap (RequesterData request)))
-> Client m (a, Event t (IntMap (RequesterData request)))
-> m (Dynamic t (a, Event t (IntMap (RequesterData request))))
forall js t (m :: * -> *) a.
Prerender js t m =>
m a -> Client m a -> m (Dynamic t a)
prerender (RequesterT t request response m a
-> Key -> m (a, Event t (IntMap (RequesterData request)))
forall (m' :: * -> *) a.
Monad m' =>
RequesterT t request response m' a
-> Key -> m' (a, Event t (IntMap (RequesterData request)))
withFannedResponses RequesterT t request response m a
server Key
0) (RequesterT t request response (Client m) a
-> Key -> Client m (a, Event t (IntMap (RequesterData request)))
forall (m' :: * -> *) a.
Monad m' =>
RequesterT t request response m' a
-> Key -> m' (a, Event t (IntMap (RequesterData request)))
withFannedResponses RequesterT t request response (Client m) a
Client (RequesterT t request response m) a
client Key
1)
    Event t (IntMap (RequesterData response))
responses <- (Event t (Entry response Multi)
 -> Event t (IntMap (RequesterData response)))
-> RequesterT t request response m (Event t (Entry response Multi))
-> RequesterT
     t request response m (Event t (IntMap (RequesterData response)))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Entry response Multi -> IntMap (RequesterData response))
-> Event t (Entry response Multi)
-> Event t (IntMap (RequesterData response))
forall k (t :: k) a b.
Reflex t =>
(a -> b) -> Event t a -> Event t b
fmapCheap Entry response Multi -> IntMap (RequesterData response)
forall (f :: * -> *). Entry f Multi -> IntMap (RequesterData f)
unMultiEntry) (RequesterT t request response m (Event t (Entry response Multi))
 -> RequesterT
      t request response m (Event t (IntMap (RequesterData response))))
-> RequesterT t request response m (Event t (Entry response Multi))
-> RequesterT
     t request response m (Event t (IntMap (RequesterData response)))
forall a b. (a -> b) -> a -> b
$ Event t (Entry request Multi)
-> RequesterT t request response m (Event t (Entry response Multi))
forall x (m :: * -> *) t (request :: * -> *) (response :: * -> *).
(MyTagTypeOffset x, Monad m) =>
Event t (Entry request x)
-> RequesterT t request response m (Event t (Entry response x))
requesting' (Event t (Entry request Multi)
 -> RequesterT
      t request response m (Event t (Entry response Multi)))
-> Event t (Entry request Multi)
-> RequesterT t request response m (Event t (Entry response Multi))
forall a b. (a -> b) -> a -> b
$ (IntMap (RequesterData request) -> Entry request Multi)
-> Event t (IntMap (RequesterData request))
-> Event t (Entry request Multi)
forall k (t :: k) a b.
Reflex t =>
(a -> b) -> Event t a -> Event t b
fmapCheap IntMap (RequesterData request) -> Entry request Multi
forall (f :: * -> *). IntMap (RequesterData f) -> Entry f Multi
multiEntry (Event t (IntMap (RequesterData request))
 -> Event t (Entry request Multi))
-> Event t (IntMap (RequesterData request))
-> Event t (Entry request Multi)
forall a b. (a -> b) -> a -> b
$ Dynamic t (Event t (IntMap (RequesterData request)))
-> Event t (IntMap (RequesterData request))
forall k (t :: k) a. Reflex t => Dynamic t (Event t a) -> Event t a
switchPromptlyDyn Dynamic t (Event t (IntMap (RequesterData request)))
requestsDyn
    Dynamic t a -> RequesterT t request response m (Dynamic t a)
forall (m :: * -> *) a. Monad m => a -> m a
return Dynamic t a
result

instance (Prerender js t m, Monad m, Reflex t, MonadFix m, Group q, Additive q, Query q, Eq q) => Prerender js t (QueryT t q m) where
  type Client (QueryT t q m) = QueryT t q (Client m)
  prerender :: QueryT t q m a
-> Client (QueryT t q m) a -> QueryT t q m (Dynamic t a)
prerender QueryT t q m a
server Client (QueryT t q m) a
client = mdo
    Dynamic t (QueryResult q)
result <- Dynamic t q -> QueryT t q m (Dynamic t (QueryResult q))
forall t q (m :: * -> *).
(Reflex t, MonadQuery t q m) =>
Dynamic t q -> m (Dynamic t (QueryResult q))
queryDyn Dynamic t q
query
    Dynamic t (a, Incremental t (AdditivePatch q))
x <- m (Dynamic t (a, Incremental t (AdditivePatch q)))
-> QueryT t q m (Dynamic t (a, Incremental t (AdditivePatch q)))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Dynamic t (a, Incremental t (AdditivePatch q)))
 -> QueryT t q m (Dynamic t (a, Incremental t (AdditivePatch q))))
-> m (Dynamic t (a, Incremental t (AdditivePatch q)))
-> QueryT t q m (Dynamic t (a, Incremental t (AdditivePatch q)))
forall a b. (a -> b) -> a -> b
$ m (a, Incremental t (AdditivePatch q))
-> Client m (a, Incremental t (AdditivePatch q))
-> m (Dynamic t (a, Incremental t (AdditivePatch q)))
forall js t (m :: * -> *) a.
Prerender js t m =>
m a -> Client m a -> m (Dynamic t a)
prerender (QueryT t q m a
-> Dynamic t (QueryResult q)
-> m (a, Incremental t (AdditivePatch q))
forall (m :: * -> *) q t a.
(MonadFix m, Additive q, Group q, Reflex t) =>
QueryT t q m a
-> Dynamic t (QueryResult q)
-> m (a, Incremental t (AdditivePatch q))
runQueryT QueryT t q m a
server Dynamic t (QueryResult q)
result) (QueryT t q (Client m) a
-> Dynamic t (QueryResult q)
-> Client m (a, Incremental t (AdditivePatch q))
forall (m :: * -> *) q t a.
(MonadFix m, Additive q, Group q, Reflex t) =>
QueryT t q m a
-> Dynamic t (QueryResult q)
-> m (a, Incremental t (AdditivePatch q))
runQueryT QueryT t q (Client m) a
Client (QueryT t q m) a
client Dynamic t (QueryResult q)
result)
    let (Dynamic t a
a, Dynamic t (Incremental t (AdditivePatch q))
inc) = Dynamic t (a, Incremental t (AdditivePatch q))
-> (Dynamic t a, Dynamic t (Incremental t (AdditivePatch q)))
forall k (t :: k) a b.
Reflex t =>
Dynamic t (a, b) -> (Dynamic t a, Dynamic t b)
splitDynPure Dynamic t (a, Incremental t (AdditivePatch q))
x
        query :: Dynamic t q
query = Incremental t (AdditivePatch q) -> Dynamic t q
forall k (t :: k) p.
(Reflex t, Patch p) =>
Incremental t p -> Dynamic t (PatchTarget p)
incrementalToDynamic (Incremental t (AdditivePatch q) -> Dynamic t q)
-> Dynamic t (Incremental t (AdditivePatch q)) -> Dynamic t q
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Dynamic t (Incremental t (AdditivePatch q))
inc -- Can we avoid the incrementalToDynamic?
    Dynamic t a -> QueryT t q m (Dynamic t a)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Dynamic t a
a

instance (Prerender js t m, Monad m) => Prerender js t (InputDisabledT m) where
  type Client (InputDisabledT m) = InputDisabledT (Client m)
  prerender :: InputDisabledT m a
-> Client (InputDisabledT m) a -> InputDisabledT m (Dynamic t a)
prerender (InputDisabledT m a
server) (InputDisabledT client) = m (Dynamic t a) -> InputDisabledT m (Dynamic t a)
forall (m :: * -> *) a. m a -> InputDisabledT m a
InputDisabledT (m (Dynamic t a) -> InputDisabledT m (Dynamic t a))
-> m (Dynamic t a) -> InputDisabledT m (Dynamic t a)
forall a b. (a -> b) -> a -> b
$ m a -> Client m a -> m (Dynamic t a)
forall js t (m :: * -> *) a.
Prerender js t m =>
m a -> Client m a -> m (Dynamic t a)
prerender m a
server Client m a
client

instance (Prerender js t m, Monad m) => Prerender js t (HydratableT m) where
  type Client (HydratableT m) = HydratableT (Client m)
  prerender :: HydratableT m a
-> Client (HydratableT m) a -> HydratableT m (Dynamic t a)
prerender (HydratableT m a
server) (HydratableT client) = m (Dynamic t a) -> HydratableT m (Dynamic t a)
forall (m :: * -> *) a. m a -> HydratableT m a
HydratableT (m (Dynamic t a) -> HydratableT m (Dynamic t a))
-> m (Dynamic t a) -> HydratableT m (Dynamic t a)
forall a b. (a -> b) -> a -> b
$ m a -> Client m a -> m (Dynamic t a)
forall js t (m :: * -> *) a.
Prerender js t m =>
m a -> Client m a -> m (Dynamic t a)
prerender m a
server Client m a
client

instance (Prerender js t m, Monad m, ReflexHost t) => Prerender js t (PostBuildT t m) where
  type Client (PostBuildT t m) = PostBuildT t (Client m)
  prerender :: PostBuildT t m a
-> Client (PostBuildT t m) a -> PostBuildT t m (Dynamic t a)
prerender PostBuildT t m a
server Client (PostBuildT t m) a
client = ReaderT (Event t ()) m (Dynamic t a)
-> PostBuildT t m (Dynamic t a)
forall t (m :: * -> *) a.
ReaderT (Event t ()) m a -> PostBuildT t m a
PostBuildT (ReaderT (Event t ()) m (Dynamic t a)
 -> PostBuildT t m (Dynamic t a))
-> ReaderT (Event t ()) m (Dynamic t a)
-> PostBuildT t m (Dynamic t a)
forall a b. (a -> b) -> a -> b
$ do
    Event t ()
pb <- ReaderT (Event t ()) m (Event t ())
forall r (m :: * -> *). MonadReader r m => m r
ask
    m (Dynamic t a) -> ReaderT (Event t ()) m (Dynamic t a)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Dynamic t a) -> ReaderT (Event t ()) m (Dynamic t a))
-> m (Dynamic t a) -> ReaderT (Event t ()) m (Dynamic t a)
forall a b. (a -> b) -> a -> b
$ m a -> Client m a -> m (Dynamic t a)
forall js t (m :: * -> *) a.
Prerender js t m =>
m a -> Client m a -> m (Dynamic t a)
prerender (PostBuildT t m a -> Event t () -> m a
forall t (m :: * -> *) a. PostBuildT t m a -> Event t () -> m a
runPostBuildT PostBuildT t m a
server Event t ()
pb) (PostBuildT t (Client m) a -> Event t () -> Client m a
forall t (m :: * -> *) a. PostBuildT t m a -> Event t () -> m a
runPostBuildT PostBuildT t (Client m) a
Client (PostBuildT t m) a
client Event t ()
pb)

startMarker, endMarker :: Text
startMarker :: Text
startMarker = Text
"prerender/start"
endMarker :: Text
endMarker = Text
"prerender/end"

deleteToPrerenderEnd :: (MonadIO m, MonadJSM m, Reflex t, MonadFix m) => DOM.Document -> HydrationRunnerT t m DOM.Comment
deleteToPrerenderEnd :: Document -> HydrationRunnerT t m Comment
deleteToPrerenderEnd Document
doc = do
  Comment
startNode <- Document
-> Text -> Maybe (Event t Text) -> HydrationRunnerT t m Comment
forall (m :: * -> *) t.
(MonadJSM m, Reflex t, MonadFix m) =>
Document
-> Text -> Maybe (Event t Text) -> HydrationRunnerT t m Comment
hydrateComment Document
doc Text
startMarker Maybe (Event t Text)
forall a. Maybe a
Nothing
  let go :: Key -> Node -> HydrationRunnerT t m Comment
go (Key
n :: Int) Node
lastNode = Node -> HydrationRunnerT t m (Maybe Node)
forall (m :: * -> *) self.
(MonadDOM m, IsNode self) =>
self -> m (Maybe Node)
Node.getNextSibling Node
lastNode HydrationRunnerT t m (Maybe Node)
-> (Maybe Node -> HydrationRunnerT t m Comment)
-> HydrationRunnerT t m Comment
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
        Maybe Node
Nothing -> do
          Comment
c <- Document -> Text -> HydrationRunnerT t m Comment
forall (m :: * -> *) self data'.
(MonadDOM m, IsDocument self, ToJSString data') =>
self -> data' -> m Comment
Document.createComment Document
doc Text
endMarker
          Comment -> HydrationRunnerT t m ()
forall (m :: * -> *) node t.
(Monad m, MonadJSM m, IsNode node) =>
node -> HydrationRunnerT t m ()
insertAfterPreviousNode Comment
c
          Comment -> HydrationRunnerT t m Comment
forall (f :: * -> *) a. Applicative f => a -> f a
pure Comment
c
        Just Node
node -> (JSVal -> Comment) -> Node -> HydrationRunnerT t m (Maybe Comment)
forall obj obj' (m :: * -> *).
(Coercible obj JSVal, IsGObject obj', MonadJSM m) =>
(JSVal -> obj') -> obj -> m (Maybe obj')
DOM.castTo JSVal -> Comment
DOM.Comment Node
node HydrationRunnerT t m (Maybe Comment)
-> (Maybe Comment -> HydrationRunnerT t m Comment)
-> HydrationRunnerT t m Comment
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
          Maybe Comment
Nothing -> Key -> Node -> HydrationRunnerT t m Comment
go Key
n Node
node
          Just Comment
c -> Comment -> HydrationRunnerT t m Text
forall (m :: * -> *) self result.
(MonadDOM m, IsNode self, FromJSString result) =>
self -> m result
Node.getTextContentUnchecked Comment
c HydrationRunnerT t m Text
-> (Text -> HydrationRunnerT t m Comment)
-> HydrationRunnerT t m Comment
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
            Text
t | Text
t Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
startMarker -> Key -> Node -> HydrationRunnerT t m Comment
go (Key -> Key
forall a. Enum a => a -> a
succ Key
n) Node
node
              | Text
t Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
endMarker -> case Key
n of
                Key
0 -> Comment -> HydrationRunnerT t m Comment
forall (f :: * -> *) a. Applicative f => a -> f a
pure Comment
c
                Key
_ -> Key -> Node -> HydrationRunnerT t m Comment
go (Key -> Key
forall a. Enum a => a -> a
pred Key
n) Node
node
              | Bool
otherwise -> Key -> Node -> HydrationRunnerT t m Comment
go Key
n Node
node
  Comment
endNode <- Key -> Node -> HydrationRunnerT t m Comment
go Key
0 (Node -> HydrationRunnerT t m Comment)
-> Node -> HydrationRunnerT t m Comment
forall a b. (a -> b) -> a -> b
$ Comment -> Node
forall o. IsNode o => o -> Node
DOM.toNode Comment
startNode
  Comment -> Comment -> HydrationRunnerT t m ()
forall (m :: * -> *) new existing.
(MonadJSM m, IsNode new, IsNode existing) =>
new -> existing -> m ()
deleteBetweenExclusive Comment
startNode Comment
endNode
  Maybe Node -> HydrationRunnerT t m ()
forall (m :: * -> *) t.
Monad m =>
Maybe Node -> HydrationRunnerT t m ()
setPreviousNode (Maybe Node -> HydrationRunnerT t m ())
-> Maybe Node -> HydrationRunnerT t m ()
forall a b. (a -> b) -> a -> b
$ Node -> Maybe Node
forall a. a -> Maybe a
Just (Node -> Maybe Node) -> Node -> Maybe Node
forall a b. (a -> b) -> a -> b
$ Comment -> Node
forall o. IsNode o => o -> Node
DOM.toNode Comment
endNode
  Comment -> HydrationRunnerT t m Comment
forall (f :: * -> *) a. Applicative f => a -> f a
pure Comment
endNode