@@ -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