{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
module Reflex.Dom.Builder.Hydratable where
import Control.Monad.Fix
import Control.Monad.Primitive
import Control.Monad.Ref
import Control.Monad.Trans
import Control.Monad.Trans.Control
import Data.Coerce
import qualified Data.Map as Map
import Foreign.JavaScript.TH
#ifndef ghcjs_HOST_OS
import GHCJS.DOM.Types (MonadJSM (..))
#endif
import Reflex
import Reflex.Dom.Builder.Class
import Reflex.Dom.Builder.Immediate (HasDocument (..), hydratableAttribute)
import Reflex.Host.Class
newtype HydratableT m a = HydratableT { HydratableT m a -> m a
runHydratableT :: m a } deriving (a -> HydratableT m b -> HydratableT m a
(a -> b) -> HydratableT m a -> HydratableT m b
(forall a b. (a -> b) -> HydratableT m a -> HydratableT m b)
-> (forall a b. a -> HydratableT m b -> HydratableT m a)
-> Functor (HydratableT m)
forall a b. a -> HydratableT m b -> HydratableT m a
forall a b. (a -> b) -> HydratableT m a -> HydratableT m b
forall (m :: * -> *) a b.
Functor m =>
a -> HydratableT m b -> HydratableT m a
forall (m :: * -> *) a b.
Functor m =>
(a -> b) -> HydratableT m a -> HydratableT m b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> HydratableT m b -> HydratableT m a
$c<$ :: forall (m :: * -> *) a b.
Functor m =>
a -> HydratableT m b -> HydratableT m a
fmap :: (a -> b) -> HydratableT m a -> HydratableT m b
$cfmap :: forall (m :: * -> *) a b.
Functor m =>
(a -> b) -> HydratableT m a -> HydratableT m b
Functor, Functor (HydratableT m)
a -> HydratableT m a
Functor (HydratableT m) =>
(forall a. a -> HydratableT m a)
-> (forall a b.
HydratableT m (a -> b) -> HydratableT m a -> HydratableT m b)
-> (forall a b c.
(a -> b -> c)
-> HydratableT m a -> HydratableT m b -> HydratableT m c)
-> (forall a b.
HydratableT m a -> HydratableT m b -> HydratableT m b)
-> (forall a b.
HydratableT m a -> HydratableT m b -> HydratableT m a)
-> Applicative (HydratableT m)
HydratableT m a -> HydratableT m b -> HydratableT m b
HydratableT m a -> HydratableT m b -> HydratableT m a
HydratableT m (a -> b) -> HydratableT m a -> HydratableT m b
(a -> b -> c)
-> HydratableT m a -> HydratableT m b -> HydratableT m c
forall a. a -> HydratableT m a
forall a b. HydratableT m a -> HydratableT m b -> HydratableT m a
forall a b. HydratableT m a -> HydratableT m b -> HydratableT m b
forall a b.
HydratableT m (a -> b) -> HydratableT m a -> HydratableT m b
forall a b c.
(a -> b -> c)
-> HydratableT m a -> HydratableT m b -> HydratableT 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
forall (m :: * -> *). Applicative m => Functor (HydratableT m)
forall (m :: * -> *) a. Applicative m => a -> HydratableT m a
forall (m :: * -> *) a b.
Applicative m =>
HydratableT m a -> HydratableT m b -> HydratableT m a
forall (m :: * -> *) a b.
Applicative m =>
HydratableT m a -> HydratableT m b -> HydratableT m b
forall (m :: * -> *) a b.
Applicative m =>
HydratableT m (a -> b) -> HydratableT m a -> HydratableT m b
forall (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c)
-> HydratableT m a -> HydratableT m b -> HydratableT m c
<* :: HydratableT m a -> HydratableT m b -> HydratableT m a
$c<* :: forall (m :: * -> *) a b.
Applicative m =>
HydratableT m a -> HydratableT m b -> HydratableT m a
*> :: HydratableT m a -> HydratableT m b -> HydratableT m b
$c*> :: forall (m :: * -> *) a b.
Applicative m =>
HydratableT m a -> HydratableT m b -> HydratableT m b
liftA2 :: (a -> b -> c)
-> HydratableT m a -> HydratableT m b -> HydratableT m c
$cliftA2 :: forall (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c)
-> HydratableT m a -> HydratableT m b -> HydratableT m c
<*> :: HydratableT m (a -> b) -> HydratableT m a -> HydratableT m b
$c<*> :: forall (m :: * -> *) a b.
Applicative m =>
HydratableT m (a -> b) -> HydratableT m a -> HydratableT m b
pure :: a -> HydratableT m a
$cpure :: forall (m :: * -> *) a. Applicative m => a -> HydratableT m a
$cp1Applicative :: forall (m :: * -> *). Applicative m => Functor (HydratableT m)
Applicative, Applicative (HydratableT m)
a -> HydratableT m a
Applicative (HydratableT m) =>
(forall a b.
HydratableT m a -> (a -> HydratableT m b) -> HydratableT m b)
-> (forall a b.
HydratableT m a -> HydratableT m b -> HydratableT m b)
-> (forall a. a -> HydratableT m a)
-> Monad (HydratableT m)
HydratableT m a -> (a -> HydratableT m b) -> HydratableT m b
HydratableT m a -> HydratableT m b -> HydratableT m b
forall a. a -> HydratableT m a
forall a b. HydratableT m a -> HydratableT m b -> HydratableT m b
forall a b.
HydratableT m a -> (a -> HydratableT m b) -> HydratableT m b
forall (m :: * -> *). Monad m => Applicative (HydratableT m)
forall (m :: * -> *) a. Monad m => a -> HydratableT m a
forall (m :: * -> *) a b.
Monad m =>
HydratableT m a -> HydratableT m b -> HydratableT m b
forall (m :: * -> *) a b.
Monad m =>
HydratableT m a -> (a -> HydratableT m b) -> HydratableT 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 -> HydratableT m a
$creturn :: forall (m :: * -> *) a. Monad m => a -> HydratableT m a
>> :: HydratableT m a -> HydratableT m b -> HydratableT m b
$c>> :: forall (m :: * -> *) a b.
Monad m =>
HydratableT m a -> HydratableT m b -> HydratableT m b
>>= :: HydratableT m a -> (a -> HydratableT m b) -> HydratableT m b
$c>>= :: forall (m :: * -> *) a b.
Monad m =>
HydratableT m a -> (a -> HydratableT m b) -> HydratableT m b
$cp1Monad :: forall (m :: * -> *). Monad m => Applicative (HydratableT m)
Monad, MonadRef (HydratableT m)
Ref (HydratableT m) a -> (a -> (a, b)) -> HydratableT m b
Ref (HydratableT m) a -> (a -> (a, b)) -> HydratableT m b
MonadRef (HydratableT m) =>
(forall a b.
Ref (HydratableT m) a -> (a -> (a, b)) -> HydratableT m b)
-> (forall a b.
Ref (HydratableT m) a -> (a -> (a, b)) -> HydratableT m b)
-> MonadAtomicRef (HydratableT m)
forall a b.
Ref (HydratableT m) a -> (a -> (a, b)) -> HydratableT m b
forall (m :: * -> *).
MonadRef m =>
(forall a b. Ref m a -> (a -> (a, b)) -> m b)
-> (forall a b. Ref m a -> (a -> (a, b)) -> m b)
-> MonadAtomicRef m
forall (m :: * -> *). MonadAtomicRef m => MonadRef (HydratableT m)
forall (m :: * -> *) a b.
MonadAtomicRef m =>
Ref (HydratableT m) a -> (a -> (a, b)) -> HydratableT m b
atomicModifyRef' :: Ref (HydratableT m) a -> (a -> (a, b)) -> HydratableT m b
$catomicModifyRef' :: forall (m :: * -> *) a b.
MonadAtomicRef m =>
Ref (HydratableT m) a -> (a -> (a, b)) -> HydratableT m b
atomicModifyRef :: Ref (HydratableT m) a -> (a -> (a, b)) -> HydratableT m b
$catomicModifyRef :: forall (m :: * -> *) a b.
MonadAtomicRef m =>
Ref (HydratableT m) a -> (a -> (a, b)) -> HydratableT m b
$cp1MonadAtomicRef :: forall (m :: * -> *). MonadAtomicRef m => MonadRef (HydratableT m)
MonadAtomicRef, Monad (HydratableT m)
Monad (HydratableT m) =>
(forall a. (a -> HydratableT m a) -> HydratableT m a)
-> MonadFix (HydratableT m)
(a -> HydratableT m a) -> HydratableT m a
forall a. (a -> HydratableT m a) -> HydratableT m a
forall (m :: * -> *).
Monad m =>
(forall a. (a -> m a) -> m a) -> MonadFix m
forall (m :: * -> *). MonadFix m => Monad (HydratableT m)
forall (m :: * -> *) a.
MonadFix m =>
(a -> HydratableT m a) -> HydratableT m a
mfix :: (a -> HydratableT m a) -> HydratableT m a
$cmfix :: forall (m :: * -> *) a.
MonadFix m =>
(a -> HydratableT m a) -> HydratableT m a
$cp1MonadFix :: forall (m :: * -> *). MonadFix m => Monad (HydratableT m)
MonadFix, Monad (HydratableT m)
Monad (HydratableT m) =>
(forall a. IO a -> HydratableT m a) -> MonadIO (HydratableT m)
IO a -> HydratableT m a
forall a. IO a -> HydratableT m a
forall (m :: * -> *).
Monad m =>
(forall a. IO a -> m a) -> MonadIO m
forall (m :: * -> *). MonadIO m => Monad (HydratableT m)
forall (m :: * -> *) a. MonadIO m => IO a -> HydratableT m a
liftIO :: IO a -> HydratableT m a
$cliftIO :: forall (m :: * -> *) a. MonadIO m => IO a -> HydratableT m a
$cp1MonadIO :: forall (m :: * -> *). MonadIO m => Monad (HydratableT m)
MonadIO)
#ifndef ghcjs_HOST_OS
instance MonadJSM m => MonadJSM (HydratableT m) where
liftJSM' :: JSM a -> HydratableT m a
liftJSM' = m a -> HydratableT m a
forall (m :: * -> *) a. m a -> HydratableT m a
HydratableT (m a -> HydratableT m a)
-> (JSM a -> m a) -> JSM a -> HydratableT m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. JSM a -> m a
forall (m :: * -> *) a. MonadJSM m => JSM a -> m a
liftJSM'
#endif
deriving instance MonadSample t m => MonadSample t (HydratableT m)
deriving instance MonadHold t m => MonadHold t (HydratableT m)
instance MonadTrans HydratableT where
lift :: m a -> HydratableT m a
lift = m a -> HydratableT m a
forall (m :: * -> *) a. m a -> HydratableT m a
HydratableT
instance MonadTransControl HydratableT where
type StT HydratableT a = a
liftWith :: (Run HydratableT -> m a) -> HydratableT m a
liftWith f :: Run HydratableT -> m a
f = m a -> HydratableT m a
forall (m :: * -> *) a. m a -> HydratableT m a
HydratableT (m a -> HydratableT m a) -> m a -> HydratableT m a
forall a b. (a -> b) -> a -> b
$ Run HydratableT -> m a
f Run HydratableT
forall (m :: * -> *) a. HydratableT m a -> m a
runHydratableT
restoreT :: m (StT HydratableT a) -> HydratableT m a
restoreT = m (StT HydratableT a) -> HydratableT m a
forall (m :: * -> *) a. m a -> HydratableT m a
HydratableT
instance MonadRef m => MonadRef (HydratableT m) where
type Ref (HydratableT m) = Ref m
newRef :: a -> HydratableT m (Ref (HydratableT m) a)
newRef = m (Ref m a) -> HydratableT m (Ref m a)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Ref m a) -> HydratableT m (Ref m a))
-> (a -> m (Ref m a)) -> a -> HydratableT m (Ref m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> m (Ref m a)
forall (m :: * -> *) a. MonadRef m => a -> m (Ref m a)
newRef
readRef :: Ref (HydratableT m) a -> HydratableT m a
readRef = m a -> HydratableT m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> HydratableT m a)
-> (Ref m a -> m a) -> Ref m a -> HydratableT m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ref m a -> m a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef
writeRef :: Ref (HydratableT m) a -> a -> HydratableT m ()
writeRef ref :: Ref (HydratableT m) a
ref = m () -> HydratableT m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> HydratableT m ()) -> (a -> m ()) -> a -> HydratableT m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ref m a -> a -> m ()
forall (m :: * -> *) a. MonadRef m => Ref m a -> a -> m ()
writeRef Ref m a
Ref (HydratableT m) a
ref
instance PerformEvent t m => PerformEvent t (HydratableT m) where
type Performable (HydratableT m) = Performable m
performEvent_ :: Event t (Performable (HydratableT m) ()) -> HydratableT m ()
performEvent_ = m () -> HydratableT m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> HydratableT m ())
-> (Event t (Performable m ()) -> m ())
-> Event t (Performable m ())
-> HydratableT m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Event t (Performable m ()) -> m ()
forall t (m :: * -> *).
PerformEvent t m =>
Event t (Performable m ()) -> m ()
performEvent_
performEvent :: Event t (Performable (HydratableT m) a)
-> HydratableT m (Event t a)
performEvent = m (Event t a) -> HydratableT m (Event t a)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Event t a) -> HydratableT m (Event t a))
-> (Event t (Performable m a) -> m (Event t a))
-> Event t (Performable m a)
-> HydratableT m (Event t a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Event t (Performable m a) -> m (Event t a)
forall t (m :: * -> *) a.
PerformEvent t m =>
Event t (Performable m a) -> m (Event t a)
performEvent
instance PrimMonad m => PrimMonad (HydratableT m) where
type PrimState (HydratableT m) = PrimState m
primitive :: (State# (PrimState (HydratableT m))
-> (# State# (PrimState (HydratableT m)), a #))
-> HydratableT m a
primitive = m a -> HydratableT m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> HydratableT m a)
-> ((State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a)
-> (State# (PrimState m) -> (# State# (PrimState m), a #))
-> HydratableT m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
forall (m :: * -> *) a.
PrimMonad m =>
(State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
primitive
makeHydratable :: Reflex t => ElementConfig er t m -> ElementConfig er t m
makeHydratable :: ElementConfig er t m -> ElementConfig er t m
makeHydratable cfg :: ElementConfig er t m
cfg = ElementConfig er t m
cfg
{ _elementConfig_initialAttributes :: Map AttributeName Text
_elementConfig_initialAttributes = AttributeName
-> Text -> Map AttributeName Text -> Map AttributeName Text
forall k a. Ord k => k -> a -> Map k a -> Map k a
Map.insert AttributeName
forall s. IsString s => s
hydratableAttribute "" (Map AttributeName Text -> Map AttributeName Text)
-> Map AttributeName Text -> Map AttributeName Text
forall a b. (a -> b) -> a -> b
$ ElementConfig er t m -> Map AttributeName Text
forall (er :: EventTag -> *) k1 (t :: k1) k2 (s :: k2).
ElementConfig er t s -> Map AttributeName Text
_elementConfig_initialAttributes ElementConfig er t m
cfg
, _elementConfig_modifyAttributes :: Maybe (Event t (Map AttributeName (Maybe Text)))
_elementConfig_modifyAttributes = (Map AttributeName (Maybe Text) -> Map AttributeName (Maybe Text))
-> Event t (Map AttributeName (Maybe Text))
-> Event t (Map AttributeName (Maybe Text))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (AttributeName
-> Map AttributeName (Maybe Text) -> Map AttributeName (Maybe Text)
forall k a. Ord k => k -> Map k a -> Map k a
Map.delete AttributeName
forall s. IsString s => s
hydratableAttribute) (Event t (Map AttributeName (Maybe Text))
-> Event t (Map AttributeName (Maybe Text)))
-> Maybe (Event t (Map AttributeName (Maybe Text)))
-> Maybe (Event t (Map AttributeName (Maybe Text)))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ElementConfig er t m
-> Maybe (Event t (Map AttributeName (Maybe Text)))
forall (er :: EventTag -> *) k1 (t :: k1) k2 (s :: k2).
ElementConfig er t s
-> Maybe (Event t (Map AttributeName (Maybe Text)))
_elementConfig_modifyAttributes ElementConfig er t m
cfg
}
instance PostBuild t m => PostBuild t (HydratableT m) where
getPostBuild :: HydratableT m (Event t ())
getPostBuild = m (Event t ()) -> HydratableT m (Event t ())
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (Event t ())
forall t (m :: * -> *). PostBuild t m => m (Event t ())
getPostBuild
deriving instance TriggerEvent t m => TriggerEvent t (HydratableT m)
instance MonadReflexCreateTrigger t m => MonadReflexCreateTrigger t (HydratableT m) where
newEventWithTrigger :: (EventTrigger t a -> IO (IO ())) -> HydratableT m (Event t a)
newEventWithTrigger = m (Event t a) -> HydratableT m (Event t a)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Event t a) -> HydratableT m (Event t a))
-> ((EventTrigger t a -> IO (IO ())) -> m (Event t a))
-> (EventTrigger t a -> IO (IO ()))
-> HydratableT m (Event t a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (EventTrigger t a -> IO (IO ())) -> m (Event t a)
forall t (m :: * -> *) a.
MonadReflexCreateTrigger t m =>
(EventTrigger t a -> IO (IO ())) -> m (Event t a)
newEventWithTrigger
newFanEventWithTrigger :: (forall a. k a -> EventTrigger t a -> IO (IO ()))
-> HydratableT m (EventSelector t k)
newFanEventWithTrigger f :: forall a. k a -> EventTrigger t a -> IO (IO ())
f = m (EventSelector t k) -> HydratableT m (EventSelector t k)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (EventSelector t k) -> HydratableT m (EventSelector t k))
-> m (EventSelector t k) -> HydratableT m (EventSelector t k)
forall a b. (a -> b) -> a -> b
$ (forall a. k a -> EventTrigger t a -> IO (IO ()))
-> m (EventSelector t k)
forall t (m :: * -> *) (k :: * -> *).
(MonadReflexCreateTrigger t m, GCompare k) =>
(forall a. k a -> EventTrigger t a -> IO (IO ()))
-> m (EventSelector t k)
newFanEventWithTrigger forall a. k a -> EventTrigger t a -> IO (IO ())
f
instance Adjustable t m => Adjustable t (HydratableT m) where
runWithReplace :: HydratableT m a
-> Event t (HydratableT m b) -> HydratableT m (a, Event t b)
runWithReplace a0 :: HydratableT m a
a0 a' :: Event t (HydratableT m b)
a' = m (a, Event t b) -> HydratableT m (a, Event t b)
forall (m :: * -> *) a. m a -> HydratableT m a
HydratableT (m (a, Event t b) -> HydratableT m (a, Event t b))
-> m (a, Event t b) -> HydratableT m (a, Event t b)
forall a b. (a -> b) -> a -> b
$ m a -> Event t (m b) -> m (a, Event t b)
forall t (m :: * -> *) a b.
Adjustable t m =>
m a -> Event t (m b) -> m (a, Event t b)
runWithReplace (HydratableT m a -> m a
forall a b. Coercible a b => a -> b
coerce HydratableT m a
a0) (Event t (HydratableT m b) -> Event t (m b)
forall k (t :: k) a b.
(Reflex t, Coercible a b) =>
Event t a -> Event t b
coerceEvent Event t (HydratableT m b)
a')
traverseDMapWithKeyWithAdjust :: (forall a. k a -> v a -> HydratableT m (v' a))
-> DMap k v
-> Event t (PatchDMap k v)
-> HydratableT m (DMap k v', Event t (PatchDMap k v'))
traverseDMapWithKeyWithAdjust f :: forall a. k a -> v a -> HydratableT m (v' a)
f dm0 :: DMap k v
dm0 dm' :: Event t (PatchDMap k v)
dm' = m (DMap k v', Event t (PatchDMap k v'))
-> HydratableT m (DMap k v', Event t (PatchDMap k v'))
forall (m :: * -> *) a. m a -> HydratableT m a
HydratableT (m (DMap k v', Event t (PatchDMap k v'))
-> HydratableT m (DMap k v', Event t (PatchDMap k v')))
-> m (DMap k v', Event t (PatchDMap k v'))
-> HydratableT m (DMap k v', Event t (PatchDMap k v'))
forall a b. (a -> b) -> a -> b
$ (forall a. k a -> v a -> m (v' a))
-> DMap k v
-> Event t (PatchDMap k v)
-> m (DMap k v', Event t (PatchDMap k v'))
forall t (m :: * -> *) (k :: * -> *) (v :: * -> *) (v' :: * -> *).
(Adjustable t m, GCompare k) =>
(forall a. k a -> v a -> m (v' a))
-> DMap k v
-> Event t (PatchDMap k v)
-> m (DMap k v', Event t (PatchDMap k v'))
traverseDMapWithKeyWithAdjust (\k :: k a
k v :: v a
v -> HydratableT m (v' a) -> m (v' a)
forall (m :: * -> *) a. HydratableT m a -> m a
runHydratableT (HydratableT m (v' a) -> m (v' a))
-> HydratableT m (v' a) -> m (v' a)
forall a b. (a -> b) -> a -> b
$ k a -> v a -> HydratableT m (v' a)
forall a. k a -> v a -> HydratableT m (v' a)
f k a
k v a
v) (DMap k v -> DMap k v
forall a b. Coercible a b => a -> b
coerce DMap k v
dm0) (Event t (PatchDMap k v) -> Event t (PatchDMap k v)
forall k (t :: k) a b.
(Reflex t, Coercible a b) =>
Event t a -> Event t b
coerceEvent Event t (PatchDMap k v)
dm')
traverseDMapWithKeyWithAdjustWithMove :: (forall a. k a -> v a -> HydratableT m (v' a))
-> DMap k v
-> Event t (PatchDMapWithMove k v)
-> HydratableT m (DMap k v', Event t (PatchDMapWithMove k v'))
traverseDMapWithKeyWithAdjustWithMove f :: forall a. k a -> v a -> HydratableT m (v' a)
f dm0 :: DMap k v
dm0 dm' :: Event t (PatchDMapWithMove k v)
dm' = m (DMap k v', Event t (PatchDMapWithMove k v'))
-> HydratableT m (DMap k v', Event t (PatchDMapWithMove k v'))
forall (m :: * -> *) a. m a -> HydratableT m a
HydratableT (m (DMap k v', Event t (PatchDMapWithMove k v'))
-> HydratableT m (DMap k v', Event t (PatchDMapWithMove k v')))
-> m (DMap k v', Event t (PatchDMapWithMove k v'))
-> HydratableT m (DMap k v', Event t (PatchDMapWithMove k v'))
forall a b. (a -> b) -> a -> b
$ (forall a. k a -> v a -> m (v' a))
-> DMap k v
-> Event t (PatchDMapWithMove k v)
-> m (DMap k v', Event t (PatchDMapWithMove k v'))
forall t (m :: * -> *) (k :: * -> *) (v :: * -> *) (v' :: * -> *).
(Adjustable t m, GCompare k) =>
(forall a. k a -> v a -> m (v' a))
-> DMap k v
-> Event t (PatchDMapWithMove k v)
-> m (DMap k v', Event t (PatchDMapWithMove k v'))
traverseDMapWithKeyWithAdjustWithMove (\k :: k a
k v :: v a
v -> HydratableT m (v' a) -> m (v' a)
forall (m :: * -> *) a. HydratableT m a -> m a
runHydratableT (HydratableT m (v' a) -> m (v' a))
-> HydratableT m (v' a) -> m (v' a)
forall a b. (a -> b) -> a -> b
$ k a -> v a -> HydratableT m (v' a)
forall a. k a -> v a -> HydratableT m (v' a)
f k a
k v a
v) (DMap k v -> DMap k v
forall a b. Coercible a b => a -> b
coerce DMap k v
dm0) (Event t (PatchDMapWithMove k v) -> Event t (PatchDMapWithMove k v)
forall k (t :: k) a b.
(Reflex t, Coercible a b) =>
Event t a -> Event t b
coerceEvent Event t (PatchDMapWithMove k v)
dm')
traverseIntMapWithKeyWithAdjust :: (Key -> v -> HydratableT m v')
-> IntMap v
-> Event t (PatchIntMap v)
-> HydratableT m (IntMap v', Event t (PatchIntMap v'))
traverseIntMapWithKeyWithAdjust f :: Key -> v -> HydratableT m v'
f m0 :: IntMap v
m0 m' :: Event t (PatchIntMap v)
m' = m (IntMap v', Event t (PatchIntMap v'))
-> HydratableT m (IntMap v', Event t (PatchIntMap v'))
forall (m :: * -> *) a. m a -> HydratableT m a
HydratableT (m (IntMap v', Event t (PatchIntMap v'))
-> HydratableT m (IntMap v', Event t (PatchIntMap v')))
-> m (IntMap v', Event t (PatchIntMap v'))
-> HydratableT m (IntMap v', Event t (PatchIntMap v'))
forall a b. (a -> b) -> a -> b
$ (Key -> v -> m v')
-> IntMap v
-> Event t (PatchIntMap v)
-> m (IntMap v', Event t (PatchIntMap v'))
forall t (m :: * -> *) v v'.
Adjustable t m =>
(Key -> v -> m v')
-> IntMap v
-> Event t (PatchIntMap v)
-> m (IntMap v', Event t (PatchIntMap v'))
traverseIntMapWithKeyWithAdjust (\k :: Key
k v :: v
v -> HydratableT m v' -> m v'
forall (m :: * -> *) a. HydratableT m a -> m a
runHydratableT (HydratableT m v' -> m v') -> HydratableT m v' -> m v'
forall a b. (a -> b) -> a -> b
$ Key -> v -> HydratableT m v'
f Key
k v
v) (IntMap v -> IntMap v
forall a b. Coercible a b => a -> b
coerce IntMap v
m0) (Event t (PatchIntMap v) -> Event t (PatchIntMap v)
forall k (t :: k) a b.
(Reflex t, Coercible a b) =>
Event t a -> Event t b
coerceEvent Event t (PatchIntMap v)
m')
instance NotReady t m => NotReady t (HydratableT m) where
notReadyUntil :: Event t a -> HydratableT m ()
notReadyUntil = m () -> HydratableT m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> HydratableT m ())
-> (Event t a -> m ()) -> Event t a -> HydratableT m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Event t a -> m ()
forall t (m :: * -> *) a. NotReady t m => Event t a -> m ()
notReadyUntil
notReady :: HydratableT m ()
notReady = m () -> HydratableT m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m ()
forall t (m :: * -> *). NotReady t m => m ()
notReady
instance DomBuilder t m => DomBuilder t (HydratableT m) where
type DomBuilderSpace (HydratableT m) = DomBuilderSpace m
element :: Text
-> ElementConfig er t (DomBuilderSpace (HydratableT m))
-> HydratableT m a
-> HydratableT
m (Element er (DomBuilderSpace (HydratableT m)) t, a)
element t :: Text
t cfg :: ElementConfig er t (DomBuilderSpace (HydratableT m))
cfg = m (Element er (DomBuilderSpace m) t, a)
-> HydratableT m (Element er (DomBuilderSpace m) t, a)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Element er (DomBuilderSpace m) t, a)
-> HydratableT m (Element er (DomBuilderSpace m) t, a))
-> (HydratableT m a -> m (Element er (DomBuilderSpace m) t, a))
-> HydratableT m a
-> HydratableT m (Element er (DomBuilderSpace m) t, a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text
-> ElementConfig er t (DomBuilderSpace m)
-> m a
-> m (Element er (DomBuilderSpace m) t, a)
forall t (m :: * -> *) (er :: EventTag -> *) a.
DomBuilder t m =>
Text
-> ElementConfig er t (DomBuilderSpace m)
-> m a
-> m (Element er (DomBuilderSpace m) t, a)
element Text
t (ElementConfig er t (DomBuilderSpace m)
-> ElementConfig er t (DomBuilderSpace m)
forall t (er :: EventTag -> *) m.
Reflex t =>
ElementConfig er t m -> ElementConfig er t m
makeHydratable ElementConfig er t (DomBuilderSpace m)
ElementConfig er t (DomBuilderSpace (HydratableT m))
cfg) (m a -> m (Element er (DomBuilderSpace m) t, a))
-> (HydratableT m a -> m a)
-> HydratableT m a
-> m (Element er (DomBuilderSpace m) t, a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HydratableT m a -> m a
forall (m :: * -> *) a. HydratableT m a -> m a
runHydratableT
inputElement :: InputElementConfig er t (DomBuilderSpace (HydratableT m))
-> HydratableT
m (InputElement er (DomBuilderSpace (HydratableT m)) t)
inputElement cfg :: InputElementConfig er t (DomBuilderSpace (HydratableT m))
cfg = m (InputElement er (DomBuilderSpace m) t)
-> HydratableT
m (InputElement er (DomBuilderSpace (HydratableT m)) t)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (InputElement er (DomBuilderSpace m) t)
-> HydratableT
m (InputElement er (DomBuilderSpace (HydratableT m)) t))
-> m (InputElement er (DomBuilderSpace m) t)
-> HydratableT
m (InputElement er (DomBuilderSpace (HydratableT m)) t)
forall a b. (a -> b) -> a -> b
$ InputElementConfig er t (DomBuilderSpace m)
-> m (InputElement er (DomBuilderSpace m) t)
forall t (m :: * -> *) (er :: EventTag -> *).
DomBuilder t m =>
InputElementConfig er t (DomBuilderSpace m)
-> m (InputElement er (DomBuilderSpace m) t)
inputElement (InputElementConfig er t (DomBuilderSpace m)
-> m (InputElement er (DomBuilderSpace m) t))
-> InputElementConfig er t (DomBuilderSpace m)
-> m (InputElement er (DomBuilderSpace m) t)
forall a b. (a -> b) -> a -> b
$ InputElementConfig er t (DomBuilderSpace m)
InputElementConfig er t (DomBuilderSpace (HydratableT m))
cfg
{ _inputElementConfig_elementConfig :: ElementConfig er t (DomBuilderSpace m)
_inputElementConfig_elementConfig = ElementConfig er t (DomBuilderSpace m)
-> ElementConfig er t (DomBuilderSpace m)
forall t (er :: EventTag -> *) m.
Reflex t =>
ElementConfig er t m -> ElementConfig er t m
makeHydratable (ElementConfig er t (DomBuilderSpace m)
-> ElementConfig er t (DomBuilderSpace m))
-> ElementConfig er t (DomBuilderSpace m)
-> ElementConfig er t (DomBuilderSpace m)
forall a b. (a -> b) -> a -> b
$ InputElementConfig er t (DomBuilderSpace m)
-> ElementConfig er t (DomBuilderSpace m)
forall (er :: EventTag -> *) k1 (t :: k1) k2 (s :: k2).
InputElementConfig er t s -> ElementConfig er t s
_inputElementConfig_elementConfig InputElementConfig er t (DomBuilderSpace m)
InputElementConfig er t (DomBuilderSpace (HydratableT m))
cfg
}
textAreaElement :: TextAreaElementConfig er t (DomBuilderSpace (HydratableT m))
-> HydratableT
m (TextAreaElement er (DomBuilderSpace (HydratableT m)) t)
textAreaElement cfg :: TextAreaElementConfig er t (DomBuilderSpace (HydratableT m))
cfg = m (TextAreaElement er (DomBuilderSpace m) t)
-> HydratableT
m (TextAreaElement er (DomBuilderSpace (HydratableT m)) t)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (TextAreaElement er (DomBuilderSpace m) t)
-> HydratableT
m (TextAreaElement er (DomBuilderSpace (HydratableT m)) t))
-> m (TextAreaElement er (DomBuilderSpace m) t)
-> HydratableT
m (TextAreaElement er (DomBuilderSpace (HydratableT m)) t)
forall a b. (a -> b) -> a -> b
$ TextAreaElementConfig er t (DomBuilderSpace m)
-> m (TextAreaElement er (DomBuilderSpace m) t)
forall t (m :: * -> *) (er :: EventTag -> *).
DomBuilder t m =>
TextAreaElementConfig er t (DomBuilderSpace m)
-> m (TextAreaElement er (DomBuilderSpace m) t)
textAreaElement (TextAreaElementConfig er t (DomBuilderSpace m)
-> m (TextAreaElement er (DomBuilderSpace m) t))
-> TextAreaElementConfig er t (DomBuilderSpace m)
-> m (TextAreaElement er (DomBuilderSpace m) t)
forall a b. (a -> b) -> a -> b
$ TextAreaElementConfig er t (DomBuilderSpace m)
TextAreaElementConfig er t (DomBuilderSpace (HydratableT m))
cfg
{ _textAreaElementConfig_elementConfig :: ElementConfig er t (DomBuilderSpace m)
_textAreaElementConfig_elementConfig = ElementConfig er t (DomBuilderSpace m)
-> ElementConfig er t (DomBuilderSpace m)
forall t (er :: EventTag -> *) m.
Reflex t =>
ElementConfig er t m -> ElementConfig er t m
makeHydratable (ElementConfig er t (DomBuilderSpace m)
-> ElementConfig er t (DomBuilderSpace m))
-> ElementConfig er t (DomBuilderSpace m)
-> ElementConfig er t (DomBuilderSpace m)
forall a b. (a -> b) -> a -> b
$ TextAreaElementConfig er t (DomBuilderSpace m)
-> ElementConfig er t (DomBuilderSpace m)
forall (er :: EventTag -> *) k1 (t :: k1) k2 (m :: k2).
TextAreaElementConfig er t m -> ElementConfig er t m
_textAreaElementConfig_elementConfig TextAreaElementConfig er t (DomBuilderSpace m)
TextAreaElementConfig er t (DomBuilderSpace (HydratableT m))
cfg
}
selectElement :: SelectElementConfig er t (DomBuilderSpace (HydratableT m))
-> HydratableT m a
-> HydratableT
m (SelectElement er (DomBuilderSpace (HydratableT m)) t, a)
selectElement cfg :: SelectElementConfig er t (DomBuilderSpace (HydratableT m))
cfg child :: HydratableT m a
child = do
let cfg' :: SelectElementConfig er t (DomBuilderSpace m)
cfg' = SelectElementConfig er t (DomBuilderSpace m)
SelectElementConfig er t (DomBuilderSpace (HydratableT m))
cfg
{ _selectElementConfig_elementConfig :: ElementConfig er t (DomBuilderSpace m)
_selectElementConfig_elementConfig = ElementConfig er t (DomBuilderSpace m)
-> ElementConfig er t (DomBuilderSpace m)
forall t (er :: EventTag -> *) m.
Reflex t =>
ElementConfig er t m -> ElementConfig er t m
makeHydratable (ElementConfig er t (DomBuilderSpace m)
-> ElementConfig er t (DomBuilderSpace m))
-> ElementConfig er t (DomBuilderSpace m)
-> ElementConfig er t (DomBuilderSpace m)
forall a b. (a -> b) -> a -> b
$ SelectElementConfig er t (DomBuilderSpace m)
-> ElementConfig er t (DomBuilderSpace m)
forall (er :: EventTag -> *) k1 (t :: k1) k2 (m :: k2).
SelectElementConfig er t m -> ElementConfig er t m
_selectElementConfig_elementConfig SelectElementConfig er t (DomBuilderSpace m)
SelectElementConfig er t (DomBuilderSpace (HydratableT m))
cfg
}
m (SelectElement er (DomBuilderSpace m) t, a)
-> HydratableT
m (SelectElement er (DomBuilderSpace (HydratableT m)) t, a)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (SelectElement er (DomBuilderSpace m) t, a)
-> HydratableT
m (SelectElement er (DomBuilderSpace (HydratableT m)) t, a))
-> m (SelectElement er (DomBuilderSpace m) t, a)
-> HydratableT
m (SelectElement er (DomBuilderSpace (HydratableT m)) t, a)
forall a b. (a -> b) -> a -> b
$ SelectElementConfig er t (DomBuilderSpace m)
-> m a -> m (SelectElement er (DomBuilderSpace m) t, a)
forall t (m :: * -> *) (er :: EventTag -> *) a.
DomBuilder t m =>
SelectElementConfig er t (DomBuilderSpace m)
-> m a -> m (SelectElement er (DomBuilderSpace m) t, a)
selectElement SelectElementConfig er t (DomBuilderSpace m)
cfg' (m a -> m (SelectElement er (DomBuilderSpace m) t, a))
-> m a -> m (SelectElement er (DomBuilderSpace m) t, a)
forall a b. (a -> b) -> a -> b
$ HydratableT m a -> m a
forall (m :: * -> *) a. HydratableT m a -> m a
runHydratableT HydratableT m a
child
instance HasDocument m => HasDocument (HydratableT m)
instance HasJSContext m => HasJSContext (HydratableT m) where
type JSContextPhantom (HydratableT m) = JSContextPhantom m
askJSContext :: HydratableT
m (JSContextSingleton (JSContextPhantom (HydratableT m)))
askJSContext = m (JSContextSingleton (JSContextPhantom m))
-> HydratableT m (JSContextSingleton (JSContextPhantom m))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (JSContextSingleton (JSContextPhantom m))
forall (m :: * -> *).
HasJSContext m =>
m (JSContextSingleton (JSContextPhantom m))
askJSContext
instance HasJS js m => HasJS js (HydratableT m) where
type JSX (HydratableT m) = JSX m
liftJS :: JSX (HydratableT m) a -> HydratableT m a
liftJS = m a -> HydratableT m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> HydratableT m a)
-> (JSX m a -> m a) -> JSX m a -> HydratableT m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. JSX m a -> m a
forall x (m :: * -> *) a. HasJS x m => JSX m a -> m a
liftJS
instance DomRenderHook t m => DomRenderHook t (HydratableT m) where
withRenderHook :: (forall x. JSM x -> JSM x) -> HydratableT m a -> HydratableT m a
withRenderHook f :: forall x. JSM x -> JSM x
f = m a -> HydratableT m a
forall (m :: * -> *) a. m a -> HydratableT m a
HydratableT (m a -> HydratableT m a)
-> (HydratableT m a -> m a) -> HydratableT m a -> HydratableT m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall x. JSM x -> JSM x) -> m a -> m a
forall k (t :: k) (m :: * -> *) a.
DomRenderHook t m =>
(forall x. JSM x -> JSM x) -> m a -> m a
withRenderHook forall x. JSM x -> JSM x
f (m a -> m a) -> (HydratableT m a -> m a) -> HydratableT m a -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HydratableT m a -> m a
forall (m :: * -> *) a. HydratableT m a -> m a
runHydratableT
requestDomAction :: Event t (JSM a) -> HydratableT m (Event t a)
requestDomAction = m (Event t a) -> HydratableT m (Event t a)
forall (m :: * -> *) a. m a -> HydratableT m a
HydratableT (m (Event t a) -> HydratableT m (Event t a))
-> (Event t (JSM a) -> m (Event t a))
-> Event t (JSM a)
-> HydratableT m (Event t a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Event t (JSM a) -> m (Event t a)
forall k (t :: k) (m :: * -> *) a.
DomRenderHook t m =>
Event t (JSM a) -> m (Event t a)
requestDomAction
requestDomAction_ :: Event t (JSM a) -> HydratableT m ()
requestDomAction_ = m () -> HydratableT m ()
forall (m :: * -> *) a. m a -> HydratableT m a
HydratableT (m () -> HydratableT m ())
-> (Event t (JSM a) -> m ()) -> Event t (JSM a) -> HydratableT m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Event t (JSM a) -> m ()
forall k (t :: k) (m :: * -> *) a.
DomRenderHook t m =>
Event t (JSM a) -> m ()
requestDomAction_