on develop help sign in
Monomorphise mainWidgetWithHead'
3010625Daniel Haraj
src/Foreign/JavaScript/TH.hs+4
@@ -186,6 +186,10 @@ instance MonadAtomicRef m => MonadAtomicRef (WithWebView x m) where
186withWebViewSingleton :: WebView -> (forall x. WebViewSingleton x -> r) -> r
186withWebViewSingleton :: WebView -> (forall x. WebViewSingleton x -> r) -> r
187withWebViewSingleton wv f = f $ WebViewSingleton wv
187withWebViewSingleton wv f = f $ WebViewSingleton wv
188
188
189+-- | Warning: `withWebViewSingletonMono` does not provide the same guarantees that `withWebViewSingleton` does.
190+withWebViewSingletonMono :: WebView -> (WebViewSingleton () -> r) -> r
191+withWebViewSingletonMono wv f = f $ WebViewSingleton wv
192+
189-- | A singleton type for a given WebView; we use this to statically guarantee that different WebViews (and thus different javscript contexts) don't get mixed up
193-- | A singleton type for a given WebView; we use this to statically guarantee that different WebViews (and thus different javscript contexts) don't get mixed up
190newtype WebViewSingleton x = WebViewSingleton { unWebViewSingleton :: WebView }
194newtype WebViewSingleton x = WebViewSingleton { unWebViewSingleton :: WebView }
191
195
src/Reflex/Dom/Internal.hs+3−2
@@ -76,8 +76,9 @@ type Widget x = PostBuildT Spider (ImmediateDomBuilderT Spider (WithWebView x (P
76attachWidget :: DOM.IsElement e => e -> WebViewSingleton x -> Widget x a -> IO a
76attachWidget :: DOM.IsElement e => e -> WebViewSingleton x -> Widget x a -> IO a
77attachWidget rootElement wv w = fst <$> attachWidget' rootElement wv w
77attachWidget rootElement wv w = fst <$> attachWidget' rootElement wv w
78
78
79+-- | Warning: `mainWidgetWithHead'` is provided only as performance tweak. It is expected to disappear in future releases.
79−mainWidgetWithHead' :: (forall x. (a -> Widget x b, b -> Widget x a)) -> IO ()
80+mainWidgetWithHead' :: (a -> Widget () b, b -> Widget () a) -> IO ()
80−mainWidgetWithHead' widgets = runWebGUI $ \webView -> withWebViewSingleton webView $ \wv -> fmap fst $ attachWidget'' $ \events -> do
81+mainWidgetWithHead' widgets = runWebGUI $ \webView -> withWebViewSingletonMono webView $ \wv -> fmap fst $ attachWidget'' $ \events -> do
81 let (headWidget, bodyWidget) = widgets
82 let (headWidget, bodyWidget) = widgets
82 Just doc <- liftIO $ fmap DOM.castToHTMLDocument <$> webViewGetDomDocument webView
83 Just doc <- liftIO $ fmap DOM.castToHTMLDocument <$> webViewGetDomDocument webView
83 Just headElement <- getHead doc
84 Just headElement <- getHead doc