on develop help sign in
Merge pull request #122 from reflex-frp/monomorphise-mainWidgetWithHead

Monomorphise mainWidgetWithHead'

commitc91c1045f5686bbc5f950b5eb78eddff340ca971 authorRyan Trinkle <ryan.trinkle@gmail.com> dateMon 26 Dec 2016, 12:22 (10 years ago) parente8b4a7c3010625
2 files changed+7−2
src/Foreign/JavaScript/TH.hs+4 src/Reflex/Dom/Internal.hs+3−2
src/Foreign/JavaScript/TH.hs+4
@@ -186,6 +186,10 @@ instance MonadAtomicRef m => MonadAtomicRef (WithWebView x m) where
186186withWebViewSingleton :: WebView -> (forall x. WebViewSingleton x -> r) -> r
187187withWebViewSingleton wv f = f $ WebViewSingleton wv
188188
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+
189193-- | 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
190194newtype WebViewSingleton x = WebViewSingleton { unWebViewSingleton :: WebView }
191195
src/Reflex/Dom/Internal.hs+3−2
@@ -76,8 +76,9 @@ type Widget x = PostBuildT Spider (ImmediateDomBuilderT Spider (WithWebView x (P
7676attachWidget :: DOM.IsElement e => e -> WebViewSingleton x -> Widget x a -> IO a
7777attachWidget rootElement wv w = fst <$> attachWidget' rootElement wv w
7878
79−mainWidgetWithHead' :: (forall x. (a -> Widget x b, b -> Widget x a)) -> IO ()
80−mainWidgetWithHead' widgets = runWebGUI $ \webView -> withWebViewSingleton webView $ \wv -> fmap fst $ attachWidget'' $ \events -> do
79+-- | Warning: `mainWidgetWithHead'` is provided only as performance tweak. It is expected to disappear in future releases.
80+mainWidgetWithHead' :: (a -> Widget () b, b -> Widget () a) -> IO ()
81+mainWidgetWithHead' widgets = runWebGUI $ \webView -> withWebViewSingletonMono webView $ \wv -> fmap fst $ attachWidget'' $ \events -> do
8182 let (headWidget, bodyWidget) = widgets
8283 Just doc <- liftIO $ fmap DOM.castToHTMLDocument <$> webViewGetDomDocument webView
8384 Just headElement <- getHead doc