on develop help sign in
add HasPostGui instances
commit0b5506fc055025bcfa94fb7d90ae5444b44a130e authorAli Abrar <aliabrar@gmail.com> dateThu 9 Apr 2015, 21:49 (12 years ago) parent103face
2 files changed+20−3
src/Reflex/Dom/Class.hs+3−2 src/Reflex/Dom/Internal.hs+17−1
src/Reflex/Dom/Class.hs+3−2
@@ -28,9 +28,10 @@ keycodeEscape :: Int
2828keycodeEscape = 27
2929
3030class ( Reflex t, MonadHold t m, MonadIO m, Functor m, MonadReflexCreateTrigger t m
31− , HasDocument m, HasWebView m, HasWebView (WidgetHost m)
31+ , HasDocument m, HasWebView m, HasWebView (WidgetHost m), HasWebView (GuiAction m)
3232 , MonadIO (WidgetHost m), MonadIO (GuiAction m), Functor (WidgetHost m), MonadSample t (WidgetHost m)
33− , HasPostGui t (GuiAction m) (WidgetHost m), HasPostGui t (GuiAction m) m, MonadRef m, MonadRef (WidgetHost m)
33+ , HasPostGui t (GuiAction m) (WidgetHost m), HasPostGui t (GuiAction m) m, HasPostGui t (GuiAction m) (GuiAction m)
34+ , MonadRef m, MonadRef (WidgetHost m)
3435 , Ref m ~ Ref IO, Ref (WidgetHost m) ~ Ref IO --TODO: Eliminate this reliance on IO
3536 , MonadFix m
3637 ) => MonadWidget t m | m -> t where
src/Reflex/Dom/Internal.hs+17−1
@@ -134,7 +134,7 @@ instance MonadReflexCreateTrigger t m => MonadReflexCreateTrigger t (Widget t m)
134134instance ( MonadRef m, Ref m ~ Ref IO, MonadRef h, Ref h ~ Ref IO --TODO: Shouldn't need to be IO
135135 , MonadIO m, MonadIO h, Functor m
136136 , ReflexHost t, MonadReflexCreateTrigger t m, MonadSample t m, MonadHold t m
137− , MonadFix m
137+ , MonadFix m, HasWebView h, HasPostGui t h h
138138 ) => MonadWidget t (Widget t (Gui t h m)) where
139139 type WidgetHost (Widget t (Gui t h m)) = Gui t h m
140140 type GuiAction (Widget t (Gui t h m)) = h
@@ -196,6 +196,22 @@ mainWidgetWithCss css w = runWebGUI $ \webView -> do
196196
197197newtype WithWebView m a = WithWebView { unWithWebView :: ReaderT WebView m a } deriving (Functor, Applicative, Monad, MonadIO, MonadFix)
198198
199+instance (Monad m) => HasWebView (WithWebView m) where
200+ askWebView = WithWebView ask
201+
202+instance HasPostGui t h m => HasPostGui t (WithWebView h) (WithWebView m) where
203+ askPostGui = do
204+ postGui <- lift askPostGui
205+ webView <- askWebView
206+ return $ \h -> postGui $ runWithWebView h webView
207+ askRunWithActions = do
208+ runWithActions <- lift askRunWithActions
209+ return $ lift . runWithActions
210+
211+instance HasPostGui Spider SpiderHost SpiderHost where
212+ askPostGui = return $ \h -> liftIO $ runSpiderHost h
213+ askRunWithActions = return fireEvents
214+
199215instance MonadTrans WithWebView where
200216 lift = WithWebView . lift
201217