on develop help sign in
Instead of transforming the data types, we use the forM, mapM and

sequence from Data.Traversable because Map and Maybe types are all instances of Traversable. The same functions from other modules are hidden too.

commitdc58a132b23b941f2e300222271daa1c1b512035 authorEric Wong <ericsyw@gmail.com> dateSat 25 Apr 2015, 16:15 (11 years ago) parentb60c6c0
1 file changed+8−5
src/Reflex/Dom/Widget/Basic.hs+8−5
src/Reflex/Dom/Widget/Basic.hs+8−5
@@ -4,6 +4,7 @@ module Reflex.Dom.Widget.Basic where
44
55import Reflex.Dom.Class
66
7+import Prelude hiding (mapM, sequence)
78import Reflex
89import Reflex.Host.Class
910import Data.Functor.Misc
@@ -12,9 +13,10 @@ import qualified Data.Map as Map
1213import Data.Set (Set)
1314import qualified Data.Set as Set
1415import Data.Dependent.Sum (DSum (..))
16+import Data.Traversable
1517import Control.Monad.Trans
16−import Control.Monad.Reader
17−import Control.Monad.State hiding (state)
18+import Control.Monad.Reader hiding (forM, mapM, sequence)
19+import Control.Monad.State hiding (state, forM, mapM, sequence)
1820import GHCJS.DOM.Node
1921import GHCJS.DOM.UIEvent
2022import GHCJS.DOM.EventM (event, EventM)
@@ -179,7 +181,7 @@ listWithKey vals mkChild = do
179181 (result, postBuild, voidAction) <- buildChild df k v
180182 return ((result, voidAction), postBuild)
181183 runFrameWithTriggerRef newChildrenTriggerRef $ fmap fst initialState --TODO: Do all these in a single runFrame
182− sequence_ $ fmap snd $ Map.elems initialState
184+ sequence $ fmap snd initialState
183185 Just p <- liftIO $ nodeGetParentNode endPlaceholder
184186 _ <- liftIO $ nodeInsertBefore p (Just df) (Just endPlaceholder)
185187 return ()
@@ -287,7 +289,7 @@ listViewWithKey' vals mkChild = do
287289 (result, postBuild, voidAction) <- buildChild df k v
288290 return ((result, voidAction), postBuild)
289291 runFrameWithTriggerRef newChildrenTriggerRef $ fmap fst initialState --TODO: Do all these in a single runFrame
290− sequence_ $ fmap snd $ Map.elems initialState
292+ sequence $ fmap snd initialState
291293 Just p <- liftIO $ nodeGetParentNode endPlaceholder
292294 _ <- liftIO $ nodeInsertBefore p (Just df) (Just endPlaceholder)
293295 return ()
@@ -373,7 +375,8 @@ wrapDomEventMaybe element elementOnevent getValue = do
373375 e <- newEventWithTrigger $ \et -> do
374376 unsubscribe <- {-# SCC "a" #-} liftIO $ {-# SCC "b" #-} elementOnevent element $ {-# SCC "c" #-} do
375377 mv <- {-# SCC "d" #-} getValue
376− forM_ (maybeToList mv) $ \v -> liftIO $ postGui $ runWithActions [et :=> v]
378+ forM mv $ \v -> liftIO $ postGui $ runWithActions [et :=> v]
379+ return ()
377380 return $ liftIO $ do
378381 {-# SCC "e" #-} unsubscribe
379382 return $! {-# SCC "f" #-} e