on develop help sign in
Fix <$, <*, and *> for Dynamics
commit41c56b605b05ebbe73c845137f076ab76b417f67 authorRyan Trinkle <ryan.trinkle@gmail.com> dateTue 31 Oct 2017, 15:38 (9 years ago) parente610225
1 file changed+3−3
src/Reflex/Spider/SpiderTimeline.include.hs+3−3
src/Reflex/Spider/SpiderTimeline.include.hs+3−3
@@ -75,7 +75,7 @@ newJoinDyn d =
7575
7676instance HasSpiderTimeline x => Functor (Reflex.Class.Dynamic (SpiderTimeline x)) where
7777 fmap f = SpiderDynamic . newMapDyn f . unSpiderDynamic
78− x <$ _ = pure x
78+ x <$ d = R.unsafeBuildDynamic (return x) $ x <$ R.updated d
7979
8080instance HasSpiderTimeline x => Applicative (Reflex.Class.Dynamic (SpiderTimeline x)) where
8181 pure = SpiderDynamic . dynamicConst
@@ -83,8 +83,8 @@ instance HasSpiderTimeline x => Applicative (Reflex.Class.Dynamic (SpiderTimelin
8383 liftA2 f a b = SpiderDynamic $ Reflex.Spider.Internal.zipDynWith f (unSpiderDynamic a) (unSpiderDynamic b)
8484#endif
8585 SpiderDynamic a <*> SpiderDynamic b = SpiderDynamic $ Reflex.Spider.Internal.zipDynWith ($) a b
86− _ *> b = b
87− a <* _ = a --TODO: The semantics of *>, <*, and <$ might not be quite right - they drop changes
86+ a *> b = R.unsafeBuildDynamic (R.sample $ R.current b) $ R.leftmost [R.updated b, R.tag (R.current b) $ R.updated a]
87+ (<*) = flip (*>) -- There are no effects, so order doesn't matter
8888
8989holdSpiderEventM :: HasSpiderTimeline x => a -> Reflex.Class.Event (SpiderTimeline x) a -> EventM x (Reflex.Class.Behavior (SpiderTimeline x) a)
9090holdSpiderEventM v0 e = fmap (SpiderBehavior . behaviorHoldIdentity) $ Reflex.Spider.Internal.hold v0 $ coerce $ unSpiderEvent e