on develop help sign in
Merge pull request #286 from reflex-frp/aa-deprecate-functormaybe
84ca5e2Ryan Trinkle
default.nix+2−2
@@ -6,7 +6,7 @@
6, template-haskell , these, time, transformers
6, template-haskell , these, time, transformers
7, transformers-compat, unbounded-delays, prim-uniq
7, transformers-compat, unbounded-delays, prim-uniq
8, data-default, filepath, directory, filemanip, ghcjs-base
8, data-default, filepath, directory, filemanip, ghcjs-base
9−, monoidal-containers
9+, monoidal-containers, witherable
10, useTemplateHaskell ? true
10, useTemplateHaskell ? true
11}:
11}:
12mkDerivation {
12mkDerivation {
@@ -21,7 +21,7 @@ mkDerivation {
21 transformers-compat prim-uniq
21 transformers-compat prim-uniq
22 base bifunctors containers deepseq dependent-map dependent-sum
22 base bifunctors containers deepseq dependent-map dependent-sum
23 mtl ref-tf split transformers data-default
23 mtl ref-tf split transformers data-default
24− random time unbounded-delays monoidal-containers
24+ random time unbounded-delays monoidal-containers witherable
25 ] ++ (if ghc.isGhcjs or false then [
25 ] ++ (if ghc.isGhcjs or false then [
26 ghcjs-base
26 ghcjs-base
27 ] else []) ++ (if !useTemplateHaskell then [] else [
27 ] else []) ++ (if !useTemplateHaskell then [] else [
reflex.cabal+3−2
@@ -1,5 +1,5 @@
1Name: reflex
1Name: reflex
2−Version: 0.5.0.1
2+Version: 0.6
3Synopsis: Higher-order Functional Reactive Programming
3Synopsis: Higher-order Functional Reactive Programming
4Description: Reflex is a high-performance, deterministic, higher-order Functional Reactive Programming system
4Description: Reflex is a high-performance, deterministic, higher-order Functional Reactive Programming system
5License: BSD3
5License: BSD3
@@ -64,7 +64,8 @@ library
64 time >= 1.4 && < 1.9,
64 time >= 1.4 && < 1.9,
65 transformers >= 0.2,
65 transformers >= 0.2,
66 transformers-compat >= 0.3,
66 transformers-compat >= 0.3,
67− unbounded-delays >= 0.1.0.0 && < 0.2
67+ unbounded-delays >= 0.1.0.0 && < 0.2,
68+ witherable >= 0.2 && < 0.4
68
69
69 exposed-modules:
70 exposed-modules:
70 Data.AppendMap,
71 Data.AppendMap,
src/Data/AppendMap.hs+6−5
@@ -26,8 +26,9 @@ import qualified Data.Map.Internal.Debug as Map (showTree, showTreeWith)
26#else
26#else
27import qualified Data.Map as Map (showTree, showTreeWith)
27import qualified Data.Map as Map (showTree, showTreeWith)
28#endif
28#endif
29−import Data.Map.Monoidal
29+import Data.Witherable (Filterable(..))
30−import Reflex.Class (FunctorMaybe (..))
30+import Data.Map.Monoidal (MonoidalMap(..), delete, null, empty)
31+import qualified Data.Map.Monoidal as M
31
32
32{-# DEPRECATED AppendMap "Use 'MonoidalMap' instead" #-}
33{-# DEPRECATED AppendMap "Use 'MonoidalMap' instead" #-}
33type AppendMap = MonoidalMap
34type AppendMap = MonoidalMap
@@ -39,8 +40,8 @@ _unAppendMap = getMonoidalMap
39pattern AppendMap :: Map k v -> MonoidalMap k v
40pattern AppendMap :: Map k v -> MonoidalMap k v
40pattern AppendMap m = MonoidalMap m
41pattern AppendMap m = MonoidalMap m
41
42
42−instance FunctorMaybe (MonoidalMap k) where
43+instance Filterable (MonoidalMap k) where
43− fmapMaybe = mapMaybe
44+ mapMaybe = M.mapMaybe
44
45
45-- | Deletes a key, returning 'Nothing' if the result is empty.
46-- | Deletes a key, returning 'Nothing' if the result is empty.
46nonEmptyDelete :: Ord k => k -> MonoidalMap k a -> Maybe (MonoidalMap k a)
47nonEmptyDelete :: Ord k => k -> MonoidalMap k a -> Maybe (MonoidalMap k a)
@@ -54,7 +55,7 @@ mapMaybeNoNull :: (a -> Maybe b)
54 -> MonoidalMap token a
55 -> MonoidalMap token a
55 -> Maybe (MonoidalMap token b)
56 -> Maybe (MonoidalMap token b)
56mapMaybeNoNull f as =
57mapMaybeNoNull f as =
57− let bs = fmapMaybe f as
58+ let bs = mapMaybe f as
58 in if null bs
59 in if null bs
59 then Nothing
60 then Nothing
60 else Just bs
61 else Just bs
src/Reflex/Class.hs+49−29
@@ -137,8 +137,10 @@ module Reflex.Class
137 -- * Unsafe functions
137 -- * Unsafe functions
138 , unsafeDynamic
138 , unsafeDynamic
139 , unsafeMapIncremental
139 , unsafeMapIncremental
140− -- * 'FunctorMaybe'
140+ -- * 'Filterable' convenience functions
141− , FunctorMaybe (..)
141+ , FunctorMaybe -- fmapMaybe is purposely not exported from deprecated 'FunctorMaybe' and the new alias is exported instead
142+ , mapMaybe -- Re-exported for convenience
143+ , fmapMaybe
142 , fforMaybe
144 , fforMaybe
143 , ffilter
145 , ffilter
144 , filterLeft
146 , filterLeft
@@ -152,6 +154,7 @@ module Reflex.Class
152 , switchPromptOnly
154 , switchPromptOnly
153 -- * "Cheap" functions
155 -- * "Cheap" functions
154 , fmapMaybeCheap
156 , fmapMaybeCheap
157+ , mapMaybeCheap
155 , fmapCheap
158 , fmapCheap
156 , fforCheap
159 , fforCheap
157 , fforMaybeCheap
160 , fforMaybeCheap
@@ -195,7 +198,10 @@ import qualified Data.Some as Some
195import Data.String
198import Data.String
196import Data.These
199import Data.These
197import Data.Type.Coercion
200import Data.Type.Coercion
201+import Data.Witherable (Filterable(..))
202+import qualified Data.Witherable as W
203+import Reflex.FunctorMaybe (FunctorMaybe)
198−import Reflex.FunctorMaybe
204+import qualified Reflex.FunctorMaybe
199import Reflex.Patch
205import Reflex.Patch
200import qualified Reflex.Patch.MapWithMove as PatchMapWithMove
206import qualified Reflex.Patch.MapWithMove as PatchMapWithMove
201
207
@@ -389,8 +395,8 @@ mapAccumMaybeMIncremental f z e = do
389 return $ case result of
395 return $ case result of
390 (Nothing, Nothing) -> Nothing
396 (Nothing, Nothing) -> Nothing
391 _ -> Just result
397 _ -> Just result
392− d' <- holdIncremental z $ fmapMaybe fst e'
398+ d' <- holdIncremental z $ mapMaybe fst e'
393− return (d', fmapMaybe snd e')
399+ return (d', mapMaybe snd e')
394
400
395slowHeadE :: (Reflex t, MonadHold t m, MonadFix m) => Event t a -> m (Event t a)
401slowHeadE :: (Reflex t, MonadHold t m, MonadFix m) => Event t a -> m (Event t a)
396slowHeadE e = do
402slowHeadE e = do
@@ -400,14 +406,14 @@ slowHeadE e = do
400
406
401-- | An 'EventSelector' allows you to efficiently 'select' an 'Event' based on a
407-- | An 'EventSelector' allows you to efficiently 'select' an 'Event' based on a
402-- key. This is much more efficient than filtering for each key with
408-- key. This is much more efficient than filtering for each key with
403−-- 'fmapMaybe'.
409+-- 'mapMaybe'.
404newtype EventSelector t k = EventSelector
410newtype EventSelector t k = EventSelector
405 { -- | Retrieve the 'Event' for the given key. The type of the 'Event' is
411 { -- | Retrieve the 'Event' for the given key. The type of the 'Event' is
406 -- determined by the type of the key, so this can be used to fan-out
412 -- determined by the type of the key, so this can be used to fan-out
407 -- 'Event's whose sub-'Event's have different types.
413 -- 'Event's whose sub-'Event's have different types.
408 --
414 --
409 -- Using 'EventSelector's and the 'fan' primitive is far more efficient than
415 -- Using 'EventSelector's and the 'fan' primitive is far more efficient than
410− -- (but equivalent to) using 'fmapMaybe' to select only the relevant
416+ -- (but equivalent to) using 'mapMaybe' to select only the relevant
411 -- occurrences of an 'Event'.
417 -- occurrences of an 'Event'.
412 select :: forall a. k a -> Event t a
418 select :: forall a. k a -> Event t a
413 }
419 }
@@ -551,22 +557,25 @@ instance (Reflex t, Semigroup a) => Semigroup (Behavior t a) where
551 times1p n = fmap $ times1p n
557 times1p n = fmap $ times1p n
552#endif
558#endif
553
559
560+-- | Alias for 'mapMaybe'
561+fmapMaybe :: Filterable f => (a -> Maybe b) -> f a -> f b
562+fmapMaybe = mapMaybe
563+
554−-- | Flipped version of 'fmapMaybe'.
564+-- | Flipped version of 'mapMaybe'.
555−fforMaybe :: FunctorMaybe f => f a -> (a -> Maybe b) -> f b
565+fforMaybe :: Filterable f => f a -> (a -> Maybe b) -> f b
556−fforMaybe = flip fmapMaybe
566+fforMaybe = flip mapMaybe
557
567
558-- | Filter 'f a' using the provided predicate.
568-- | Filter 'f a' using the provided predicate.
559−-- Relies on 'fforMaybe'.
560−ffilter :: FunctorMaybe f => (a -> Bool) -> f a -> f a
569+ffilter :: Filterable f => (a -> Bool) -> f a -> f a
561−ffilter f = fmapMaybe $ \x -> if f x then Just x else Nothing
570+ffilter = W.filter
562
571
563-- | Filter 'Left's from 'f (Either a b)' into 'a'.
572-- | Filter 'Left's from 'f (Either a b)' into 'a'.
564−filterLeft :: FunctorMaybe f => f (Either a b) -> f a
573+filterLeft :: Filterable f => f (Either a b) -> f a
565−filterLeft = fmapMaybe (either Just (const Nothing))
574+filterLeft = mapMaybe (either Just (const Nothing))
566
575
567-- | Filter 'Right's from 'f (Either a b)' into 'b'.
576-- | Filter 'Right's from 'f (Either a b)' into 'b'.
568−filterRight :: FunctorMaybe f => f (Either a b) -> f b
577+filterRight :: Filterable f => f (Either a b) -> f b
569−filterRight = fmapMaybe (either (const Nothing) Just)
578+filterRight = mapMaybe (either (const Nothing) Just)
570
579
571-- | Left-biased event union (prefers left event on simultaneous
580-- | Left-biased event union (prefers left event on simultaneous
572-- occurrence).
581-- occurrence).
@@ -584,13 +593,18 @@ instance Reflex t => Bind (Event t) where
584
593
585instance Reflex t => Functor (Event t) where
594instance Reflex t => Functor (Event t) where
586 {-# INLINE fmap #-}
595 {-# INLINE fmap #-}
587− fmap f = fmapMaybe $ Just . f
596+ fmap f = mapMaybe $ Just . f
588 {-# INLINE (<$) #-}
597 {-# INLINE (<$) #-}
589 x <$ e = fmapCheap (const x) e
598 x <$ e = fmapCheap (const x) e
590
599
600+-- TODO Remove this instance
591instance Reflex t => FunctorMaybe (Event t) where
601instance Reflex t => FunctorMaybe (Event t) where
592 {-# INLINE fmapMaybe #-}
602 {-# INLINE fmapMaybe #-}
603+ fmapMaybe = mapMaybe
604+
605+instance Reflex t => Filterable (Event t) where
606+ {-# INLINE mapMaybe #-}
593− fmapMaybe f = push $ return . f
607+ mapMaybe f = push $ return . f
594
608
595-- | Never: @'zero' = 'never'@.
609-- | Never: @'zero' = 'never'@.
596instance Reflex t => Plus (Event t) where
610instance Reflex t => Plus (Event t) where
@@ -808,7 +822,7 @@ fanEither :: Reflex t => Event t (Either a b) -> (Event t a, Event t b)
808fanEither e =
822fanEither e =
809 let justLeft = either Just (const Nothing)
823 let justLeft = either Just (const Nothing)
810 justRight = either (const Nothing) Just
824 justRight = either (const Nothing) Just
811− in (fmapMaybe justLeft e, fmapMaybe justRight e)
825+ in (mapMaybe justLeft e, mapMaybe justRight e)
812
826
813-- | Split the event into separate events for 'This' and 'That' values,
827-- | Split the event into separate events for 'This' and 'That' values,
814-- allowing them to fire simultaneously when the input value is 'These'.
828-- allowing them to fire simultaneously when the input value is 'These'.
@@ -820,7 +834,7 @@ fanThese e =
820 that (That y) = Just y
834 that (That y) = Just y
821 that (These _ y) = Just y
835 that (These _ y) = Just y
822 that _ = Nothing
836 that _ = Nothing
823− in (fmapMaybe this e, fmapMaybe that e)
837+ in (mapMaybe this e, mapMaybe that e)
824
838
825-- | Split the event into an 'EventSelector' that allows efficient selection of
839-- | Split the event into an 'EventSelector' that allows efficient selection of
826-- the individual 'Event's.
840-- the individual 'Event's.
@@ -1004,7 +1018,7 @@ difference = alignEventWithMaybe $ \case
1004-- | Zips two values by taking the union of their shapes and combining with the provided function.
1018-- | Zips two values by taking the union of their shapes and combining with the provided function.
1005-- 'Nothing' values are dropped.
1019-- 'Nothing' values are dropped.
1006alignEventWithMaybe :: Reflex t => (These a b -> Maybe c) -> Event t a -> Event t b -> Event t c
1020alignEventWithMaybe :: Reflex t => (These a b -> Maybe c) -> Event t a -> Event t b -> Event t c
1007−alignEventWithMaybe f ea eb = fmapMaybe (f <=< dmapToThese) $
1021+alignEventWithMaybe f ea eb = mapMaybe (f <=< dmapToThese) $
1008 merge $ DMap.fromList [LeftTag :=> ea, RightTag :=> eb]
1022 merge $ DMap.fromList [LeftTag :=> ea, RightTag :=> eb]
1009
1023
1010-- | Produces an 'Event' that fires only when the input event fires with a 'DSum' key that
1024-- | Produces an 'Event' that fires only when the input event fires with a 'DSum' key that
@@ -1174,8 +1188,8 @@ mapAccumMaybeMDyn f z e = do
1174 return $ case result of
1188 return $ case result of
1175 (Nothing, Nothing) -> Nothing
1189 (Nothing, Nothing) -> Nothing
1176 _ -> Just result
1190 _ -> Just result
1177− d' <- holdDyn z $ fmapMaybe fst e'
1191+ d' <- holdDyn z $ mapMaybe fst e'
1178− return (d', fmapMaybe snd e')
1192+ return (d', mapMaybe snd e')
1179
1193
1180-- | Accumulate a 'Behavior' by folding occurrences of an 'Event'
1194-- | Accumulate a 'Behavior' by folding occurrences of an 'Event'
1181-- with the provided function.
1195-- with the provided function.
@@ -1263,8 +1277,8 @@ mapAccumMaybeMB f z e = do
1263 return $ case result of
1277 return $ case result of
1264 (Nothing, Nothing) -> Nothing
1278 (Nothing, Nothing) -> Nothing
1265 _ -> Just result
1279 _ -> Just result
1266− d' <- hold z $ fmapMaybe fst e'
1280+ d' <- hold z $ mapMaybe fst e'
1267− return (d', fmapMaybe snd e')
1281+ return (d', mapMaybe snd e')
1268
1282
1269-- | Accumulate occurrences of an 'Event', producing an output occurrence each
1283-- | Accumulate occurrences of an 'Event', producing an output occurrence each
1270-- time. Discard the underlying 'Accumulator'.
1284-- time. Discard the underlying 'Accumulator'.
@@ -1413,15 +1427,21 @@ infixl 4 <@
1413pushAlwaysCheap :: Reflex t => (a -> PushM t b) -> Event t a -> Event t b
1427pushAlwaysCheap :: Reflex t => (a -> PushM t b) -> Event t a -> Event t b
1414pushAlwaysCheap f = pushCheap (fmap Just . f)
1428pushAlwaysCheap f = pushCheap (fmap Just . f)
1415
1429
1416−-- | A "cheap" version of 'fmapMaybe'. See the performance note on 'pushCheap'.
1430+-- | A "cheap" version of 'mapMaybe'. See the performance note on 'pushCheap'.
1431+{-# INLINE mapMaybeCheap #-}
1432+mapMaybeCheap :: Reflex t => (a -> Maybe b) -> Event t a -> Event t b
1433+mapMaybeCheap f = pushCheap $ return . f
1434+
1435+-- | An alias for 'mapMaybeCheap'
1417{-# INLINE fmapMaybeCheap #-}
1436{-# INLINE fmapMaybeCheap #-}
1418fmapMaybeCheap :: Reflex t => (a -> Maybe b) -> Event t a -> Event t b
1437fmapMaybeCheap :: Reflex t => (a -> Maybe b) -> Event t a -> Event t b
1419−fmapMaybeCheap f = pushCheap $ return . f
1438+fmapMaybeCheap = mapMaybeCheap
1439+
1420
1440
1421-- | A "cheap" version of 'fforMaybe'. See the performance note on 'pushCheap'.
1441-- | A "cheap" version of 'fforMaybe'. See the performance note on 'pushCheap'.
1422{-# INLINE fforMaybeCheap #-}
1442{-# INLINE fforMaybeCheap #-}
1423fforMaybeCheap :: Reflex t => Event t a -> (a -> Maybe b) -> Event t b
1443fforMaybeCheap :: Reflex t => Event t a -> (a -> Maybe b) -> Event t b
1424−fforMaybeCheap = flip fmapMaybeCheap
1444+fforMaybeCheap = flip mapMaybeCheap
1425
1445
1426-- | A "cheap" version of 'ffor'. See the performance note on 'pushCheap'.
1446-- | A "cheap" version of 'ffor'. See the performance note on 'pushCheap'.
1427{-# INLINE fforCheap #-}
1447{-# INLINE fforCheap #-}
src/Reflex/FunctorMaybe.hs+6−19
@@ -13,46 +13,33 @@ module Reflex.FunctorMaybe
13 ) where
13 ) where
14
14
15import Data.IntMap (IntMap)
15import Data.IntMap (IntMap)
16−import qualified Data.IntMap as IntMap
17import Data.Map (Map)
16import Data.Map (Map)
18−import qualified Data.Map as Map
19−import Data.Maybe
20#if MIN_VERSION_base(4,9,0)
17#if MIN_VERSION_base(4,9,0)
21import Data.Semigroup (Option(..))
18import Data.Semigroup (Option(..))
22#endif
19#endif
20+import Data.Witherable
23
21
24--TODO: See if there's a better class in the standard libraries already
22--TODO: See if there's a better class in the standard libraries already
25
23
26-- | A class for values that combines filtering and mapping using 'Maybe'.
24-- | A class for values that combines filtering and mapping using 'Maybe'.
27−-- Morally, @'FunctorMaybe' ~ KleisliFunctor 'Maybe'@. Also similar is the
25+-- Morally, @'FunctorMaybe' ~ KleisliFunctor 'Maybe'@.
28−-- @Witherable@ typeclass, but it requires @'Foldable' f@ and @'Traversable' f@,
26+{-# DEPRECATED FunctorMaybe "Use 'Filterable' from Data.Witherable instead" #-}
29−-- and e.g. 'Event' is instance of neither.
30−--
31−-- A definition of 'fmapMaybe' must satisfy the following laws:
32−--
33−-- [/identity/]
34−-- @'fmapMaybe' 'Just' ≡ 'id'@
35−--
36−-- [/composition/]
37−-- @'fmapMaybe' (f <=< g) ≡ 'fmapMaybe' f . 'fmapMaybe' g@
38class FunctorMaybe f where
27class FunctorMaybe f where
39 -- | Combined mapping and filtering function.
28 -- | Combined mapping and filtering function.
40 fmapMaybe :: (a -> Maybe b) -> f a -> f b
29 fmapMaybe :: (a -> Maybe b) -> f a -> f b
41
30
42−-- | @fmapMaybe = (=<<)
43instance FunctorMaybe Maybe where
31instance FunctorMaybe Maybe where
44− fmapMaybe = (=<<)
32+ fmapMaybe = mapMaybe
45
33
46#if MIN_VERSION_base(4,9,0)
34#if MIN_VERSION_base(4,9,0)
47deriving instance FunctorMaybe Option
35deriving instance FunctorMaybe Option
48#endif
36#endif
49
37
50−-- | @fmapMaybe = mapMaybe@
51instance FunctorMaybe [] where
38instance FunctorMaybe [] where
52 fmapMaybe = mapMaybe
39 fmapMaybe = mapMaybe
53
40
54instance FunctorMaybe (Map k) where
41instance FunctorMaybe (Map k) where
55− fmapMaybe = Map.mapMaybe
42+ fmapMaybe = mapMaybe
56
43
57instance FunctorMaybe IntMap where
44instance FunctorMaybe IntMap where
58− fmapMaybe = IntMap.mapMaybe
45+ fmapMaybe = mapMaybe
src/Reflex/Requester/Base.hs+2−2
@@ -393,7 +393,7 @@ traverseIntMapWithKeyWithAdjustRequesterTWith base patchNewElements mergePatchIn
393 pack = Entry
393 pack = Entry
394 f' :: IntMap.Key -> (Int, v) -> m (Event t (IntMap (RequesterData request)), v')
394 f' :: IntMap.Key -> (Int, v) -> m (Event t (IntMap (RequesterData request)), v')
395 f' k (n, v) = do
395 f' k (n, v) = do
396− (result, myRequests) <- runRequesterT (f k v) $ fmapMaybeCheap (IntMap.lookup n) $ selectInt responses k --TODO: Instead of doing fmapMaybeCheap, can we share a fanInt across all instances of a given key, or at least the ones that are adjacent in time?
396+ (result, myRequests) <- runRequesterT (f k v) $ mapMaybeCheap (IntMap.lookup n) $ selectInt responses k --TODO: Instead of doing mapMaybeCheap, can we share a fanInt across all instances of a given key, or at least the ones that are adjacent in time?
397 return (fmapCheap (IntMap.singleton n) myRequests, result)
397 return (fmapCheap (IntMap.singleton n) myRequests, result)
398 ndm' <- numberOccurrencesFrom 1 dm'
398 ndm' <- numberOccurrencesFrom 1 dm'
399 (children0, children') <- base f' (fmap ((,) 0) dm0) $ fmap (\(n, dm) -> fmap ((,) n) dm) ndm' --TODO: Avoid this somehow, probably by adding some sort of per-cohort information passing to Adjustable
399 (children0, children') <- base f' (fmap ((,) 0) dm0) $ fmap (\(n, dm) -> fmap ((,) n) dm) ndm' --TODO: Avoid this somehow, probably by adding some sort of per-cohort information passing to Adjustable
@@ -441,7 +441,7 @@ traverseDMapWithKeyWithAdjustRequesterTWith base mapPatch weakenPatchWith patchN
441 pack = Entry
441 pack = Entry
442 f' :: forall a. k a -> Compose ((,) Int) v a -> m (Compose ((,) (Event t (IntMap (RequesterData request)))) v' a)
442 f' :: forall a. k a -> Compose ((,) Int) v a -> m (Compose ((,) (Event t (IntMap (RequesterData request)))) v' a)
443 f' k (Compose (n, v)) = do
443 f' k (Compose (n, v)) = do
444− (result, myRequests) <- runRequesterT (f k v) $ fmapMaybeCheap (IntMap.lookup n) $ select responses (Const2 (Some.This k))
444+ (result, myRequests) <- runRequesterT (f k v) $ mapMaybeCheap (IntMap.lookup n) $ select responses (Const2 (Some.This k))
445 return $ Compose (fmapCheap (IntMap.singleton n) myRequests, result)
445 return $ Compose (fmapCheap (IntMap.singleton n) myRequests, result)
446 ndm' <- numberOccurrencesFrom 1 dm'
446 ndm' <- numberOccurrencesFrom 1 dm'
447 (children0, children') <- base f' (DMap.map (\v -> Compose (0, v)) dm0) $ fmap (\(n, dm) -> mapPatch (\v -> Compose (n, v)) dm) ndm'
447 (children0, children') <- base f' (DMap.map (\v -> Compose (0, v)) dm0) $ fmap (\(n, dm) -> mapPatch (\v -> Compose (n, v)) dm) ndm'
src/Reflex/Spider/Internal.hs+5−5
@@ -49,16 +49,16 @@ import Data.GADT.Compare
49import Data.IntMap.Strict (IntMap)
49import Data.IntMap.Strict (IntMap)
50import qualified Data.IntMap.Strict as IntMap
50import qualified Data.IntMap.Strict as IntMap
51import Data.IORef
51import Data.IORef
52−import Data.Maybe
52+import Data.Maybe hiding (mapMaybe)
53import Data.Monoid ((<>))
53import Data.Monoid ((<>))
54import Data.Proxy
54import Data.Proxy
55import Data.These
55import Data.These
56import Data.Traversable
56import Data.Traversable
57+import Data.Witherable (Filterable, mapMaybe)
57import GHC.Exts
58import GHC.Exts
58import GHC.IORef (IORef (..))
59import GHC.IORef (IORef (..))
59import GHC.Stack
60import GHC.Stack
60import Reflex.FastWeak
61import Reflex.FastWeak
61−import Reflex.FunctorMaybe
62import System.IO.Unsafe
62import System.IO.Unsafe
63import System.Mem.Weak
63import System.Mem.Weak
64import Unsafe.Coerce
64import Unsafe.Coerce
@@ -1128,12 +1128,12 @@ newInvalidatorSwitch subd = return $! InvalidatorSwitch subd
1128newInvalidatorPull :: Pull x a -> IO (Invalidator x)
1128newInvalidatorPull :: Pull x a -> IO (Invalidator x)
1129newInvalidatorPull p = return $! InvalidatorPull p
1129newInvalidatorPull p = return $! InvalidatorPull p
1130
1130
1131−instance HasSpiderTimeline x => FunctorMaybe (Event x) where
1131+instance HasSpiderTimeline x => Filterable (Event x) where
1132− fmapMaybe f = push $ return . f
1132+ mapMaybe f = push $ return . f
1133
1133
1134instance HasSpiderTimeline x => Align (Event x) where
1134instance HasSpiderTimeline x => Align (Event x) where
1135 nil = eventNever
1135 nil = eventNever
1136− align ea eb = fmapMaybe dmapToThese $ merge $ dynamicConst $ DMap.fromDistinctAscList [LeftTag :=> ea, RightTag :=> eb]
1136+ align ea eb = mapMaybe dmapToThese $ merge $ dynamicConst $ DMap.fromDistinctAscList [LeftTag :=> ea, RightTag :=> eb]
1137
1137
1138data DynType x p = UnsafeDyn !(BehaviorM x (PatchTarget p), Event x p)
1138data DynType x p = UnsafeDyn !(BehaviorM x (PatchTarget p), Event x p)
1139 | BuildDyn !(EventM x (PatchTarget p), Event x p)
1139 | BuildDyn !(EventM x (PatchTarget p), Event x p)