on develop help sign in
Merge pull request #128 from reflex-frp/dan-perf
ef8a2f4Ryan Trinkle
reflex-dom.cabal+8
@@ -25,6 +25,11 @@ flag use-reflex-optimizer
25 default: False
25 default: False
26 manual: True
26 manual: True
27
27
28+flag expose-all-unfoldings
29+ description: Build the library with -fexpose-all-unfoldings which can help client code specialize better
30+ default: False
31+ manual: True
32+
28library
33library
29 hs-source-dirs: src
34 hs-source-dirs: src
30 build-depends:
35 build-depends:
@@ -109,6 +114,9 @@ library
109 other-extensions: TemplateHaskell
114 other-extensions: TemplateHaskell
110 ghc-options: -Wall -fwarn-tabs -funbox-strict-fields -O2 -ferror-spans
115 ghc-options: -Wall -fwarn-tabs -funbox-strict-fields -O2 -ferror-spans
111
116
117+ if flag(expose-all-unfoldings)
118+ ghc-options: -fexpose-all-unfoldings
119+
112 if flag(use-reflex-optimizer)
120 if flag(use-reflex-optimizer)
113 ghc-options: -fplugin=Reflex.Optimizer
121 ghc-options: -fplugin=Reflex.Optimizer
114
122
src/Foreign/JavaScript/TH.hs+5
@@ -22,6 +22,7 @@ module Foreign.JavaScript.TH ( module Foreign.JavaScript.TH
22
22
23import Reflex.Class
23import Reflex.Class
24import Reflex.DynamicWriter
24import Reflex.DynamicWriter
25+import Reflex.EventWriter
25import Reflex.Host.Class
26import Reflex.Host.Class
26import Reflex.PerformEvent.Base
27import Reflex.PerformEvent.Base
27import Reflex.PerformEvent.Class
28import Reflex.PerformEvent.Class
@@ -110,6 +111,10 @@ instance HasWebView m => HasWebView (DynamicWriterT t w m) where
110 type WebViewPhantom (DynamicWriterT t w m) = WebViewPhantom m
111 type WebViewPhantom (DynamicWriterT t w m) = WebViewPhantom m
111 askWebView = lift askWebView
112 askWebView = lift askWebView
112
113
114+instance HasWebView m => HasWebView (EventWriterT t w m) where
115+ type WebViewPhantom (EventWriterT t w m) = WebViewPhantom m
116+ askWebView = lift askWebView
117+
113instance HasWebView m => HasWebView (RequesterT t request response m) where
118instance HasWebView m => HasWebView (RequesterT t request response m) where
114 type WebViewPhantom (RequesterT t request response m) = WebViewPhantom m
119 type WebViewPhantom (RequesterT t request response m) = WebViewPhantom m
115 askWebView = lift askWebView
120 askWebView = lift askWebView
src/Reflex/Dom/Builder/Static.hs+3−3
@@ -147,9 +147,9 @@ instance (Reflex t, MonadAdjust t m, MonadHold t m) => MonadAdjust t (StaticDomB
147 runWithReplace a0 a' = do
147 runWithReplace a0 a' = do
148 e <- StaticDomBuilderT ask
148 e <- StaticDomBuilderT ask
149 (result0, result') <- lift $ runWithReplace (runStaticDomBuilderT a0 e) (flip runStaticDomBuilderT e <$> a')
149 (result0, result') <- lift $ runWithReplace (runStaticDomBuilderT a0 e) (flip runStaticDomBuilderT e <$> a')
150− o <- hold (snd result0) $ snd <$> result'
150+ o <- hold (snd result0) $ fmapCheap snd result'
151 StaticDomBuilderT $ modify $ (:) $ join o
151 StaticDomBuilderT $ modify $ (:) $ join o
152− return (fst result0, fst <$> result')
152+ return (fst result0, fmapCheap fst result')
153 sequenceDMapWithAdjust (dm0 :: DMap k (StaticDomBuilderT t m)) dm' = do
153 sequenceDMapWithAdjust (dm0 :: DMap k (StaticDomBuilderT t m)) dm' = do
154 e <- StaticDomBuilderT ask
154 e <- StaticDomBuilderT ask
155 let loweredDm0 = mapKeyValuePairsMonotonic (\(k :=> v) -> WrapArg k :=> fmap swap (runStaticDomBuilderT v e)) dm0
155 let loweredDm0 = mapKeyValuePairsMonotonic (\(k :=> v) -> WrapArg k :=> fmap swap (runStaticDomBuilderT v e)) dm0
@@ -178,7 +178,7 @@ instance SupportsStaticDomBuilder t m => DomBuilder t (StaticDomBuilderT t m) wh
178 --TODO: Do not escape quotation marks; see https://stackoverflow.com/questions/25612166/what-characters-must-be-escaped-in-html-5
178 --TODO: Do not escape quotation marks; see https://stackoverflow.com/questions/25612166/what-characters-must-be-escaped-in-html-5
179 shouldEscape <- asks _staticDomBuilderEnv_shouldEscape
179 shouldEscape <- asks _staticDomBuilderEnv_shouldEscape
180 let escape = if shouldEscape then fromHtmlEscapedText else byteString . encodeUtf8
180 let escape = if shouldEscape then fromHtmlEscapedText else byteString . encodeUtf8
181− modify . (:) <=< hold (escape initialContents) $ fmap escape setContents
181+ modify . (:) <=< hold (escape initialContents) $ fmapCheap escape setContents --Only because it doesn't get optimized when profiling is on
182 return $ TextNode ()
182 return $ TextNode ()
183 {-# INLINABLE element #-}
183 {-# INLINABLE element #-}
184 element elementTag cfg child = do
184 element elementTag cfg child = do
src/Reflex/Dom/Widget/Basic.hs+5−1
@@ -71,6 +71,7 @@ module Reflex.Dom.Widget.Basic
71 , workflow
71 , workflow
72 , workflowView
72 , workflowView
73 , mapWorkflow
73 , mapWorkflow
74+ , mapWorkflowCheap
74
75
75 -- * Tables and Lists
76 -- * Tables and Lists
76 , tableDynAttr
77 , tableDynAttr
@@ -160,7 +161,7 @@ button t = do
160dyn :: (DomBuilder t m, PostBuild t m) => Dynamic t (m a) -> m (Event t a)
161dyn :: (DomBuilder t m, PostBuild t m) => Dynamic t (m a) -> m (Event t a)
161dyn child = do
162dyn child = do
162 postBuild <- getPostBuild
163 postBuild <- getPostBuild
163− let newChild = leftmost [updated child, tag (current child) postBuild]
164+ let newChild = leftmost [updated child, tagCheap (current child) postBuild]
164 snd <$> widgetHoldInternal (return ()) newChild
165 snd <$> widgetHoldInternal (return ()) newChild
165
166
166-- | Given an initial widget and an Event of widget-creating actions, create a widget that is recreated whenever the Event fires.
167-- | Given an initial widget and an Event of widget-creating actions, create a widget that is recreated whenever the Event fires.
@@ -423,6 +424,9 @@ workflowView w0 = do
423mapWorkflow :: (DomBuilder t m) => (a -> b) -> Workflow t m a -> Workflow t m b
424mapWorkflow :: (DomBuilder t m) => (a -> b) -> Workflow t m a -> Workflow t m b
424mapWorkflow f (Workflow x) = Workflow (fmap (f *** fmap (mapWorkflow f)) x)
425mapWorkflow f (Workflow x) = Workflow (fmap (f *** fmap (mapWorkflow f)) x)
425
426
427+mapWorkflowCheap :: (DomBuilder t m) => (a -> b) -> Workflow t m a -> Workflow t m b
428+mapWorkflowCheap f (Workflow x) = Workflow (fmap (f *** fmapCheap (mapWorkflowCheap f)) x)
429+
426-- | A widget to display a table with static columns and dynamic rows.
430-- | A widget to display a table with static columns and dynamic rows.
427tableDynAttr :: forall t m r k v. (Ord k, DomBuilder t m, MonadHold t m, PostBuild t m, MonadFix m)
431tableDynAttr :: forall t m r k v. (Ord k, DomBuilder t m, MonadHold t m, PostBuild t m, MonadFix m)
428 => Text -- ^ Class applied to <table> element
432 => Text -- ^ Class applied to <table> element