on develop help sign in
Deprecate FunctorMaybe in favor of Filterable
bef906eAli Abrar
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+2−1
@@ -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
@@ -31,9 +31,10 @@ import qualified Data.Map.Internal.Debug as Map (showTree, showTreeWith)
31#else
31#else
32import qualified Data.Map as Map (showTree, showTreeWith)
32import qualified Data.Map as Map (showTree, showTreeWith)
33#endif
33#endif
34−import Data.Map.Monoidal
35−import Reflex.Class (FunctorMaybe (..))
36import Reflex.Patch (Additive, Group (..))
34import Reflex.Patch (Additive, Group (..))
35+import Data.Map.Monoidal hiding (mapMaybe)
36+import qualified Data.Map.Monoidal as M
37+import Data.Witherable (Filterable(..))
37
38
38{-# DEPRECATED AppendMap "Use 'MonoidalMap' instead" #-}
39{-# DEPRECATED AppendMap "Use 'MonoidalMap' instead" #-}
39type AppendMap = MonoidalMap
40type AppendMap = MonoidalMap
@@ -45,8 +46,8 @@ _unAppendMap = getMonoidalMap
45pattern AppendMap :: Map k v -> MonoidalMap k v
46pattern AppendMap :: Map k v -> MonoidalMap k v
46pattern AppendMap m = MonoidalMap m
47pattern AppendMap m = MonoidalMap m
47
48
48−instance FunctorMaybe (MonoidalMap k) where
49+instance Filterable (MonoidalMap k) where
49− fmapMaybe = mapMaybe
50+ mapMaybe = M.mapMaybe
50
51
51-- | Deletes a key, returning 'Nothing' if the result is empty.
52-- | Deletes a key, returning 'Nothing' if the result is empty.
52nonEmptyDelete :: Ord k => k -> MonoidalMap k a -> Maybe (MonoidalMap k a)
53nonEmptyDelete :: Ord k => k -> MonoidalMap k a -> Maybe (MonoidalMap k a)
@@ -60,7 +61,7 @@ mapMaybeNoNull :: (a -> Maybe b)
60 -> MonoidalMap token a
61 -> MonoidalMap token a
61 -> Maybe (MonoidalMap token b)
62 -> Maybe (MonoidalMap token b)
62mapMaybeNoNull f as =
63mapMaybeNoNull f as =
63− let bs = fmapMaybe f as
64+ let bs = mapMaybe f as
64 in if null bs
65 in if null bs
65 then Nothing
66 then Nothing
66 else Just bs
67 else Just bs
src/Reflex/Class.hs+49−28
@@ -133,8 +133,9 @@ module Reflex.Class
133 -- * Unsafe functions
133 -- * Unsafe functions
134 , unsafeDynamic
134 , unsafeDynamic
135 , unsafeMapIncremental
135 , unsafeMapIncremental
136− -- * 'FunctorMaybe'
136+ -- * 'Filterable' convenience functions
137− , FunctorMaybe (..)
137+ , FunctorMaybe -- fmapMaybe is purposely not exported from deprecated 'FunctorMaybe' and the new alias is exported instead
138+ , fmapMaybe
138 , fforMaybe
139 , fforMaybe
139 , ffilter
140 , ffilter
140 , filterLeft
141 , filterLeft
@@ -147,6 +148,7 @@ module Reflex.Class
147 , appendEvents
148 , appendEvents
148 , onceE
149 , onceE
149 , sequenceThese
150 , sequenceThese
151+ , mapMaybeCheap
150 , fmapMaybeCheap
152 , fmapMaybeCheap
151 , fmapCheap
153 , fmapCheap
152 , fforCheap
154 , fforCheap
@@ -193,7 +195,10 @@ import qualified Data.Some as Some
193import Data.String
195import Data.String
194import Data.These
196import Data.These
195import Data.Type.Coercion
197import Data.Type.Coercion
198+import Data.Witherable (Filterable(..))
199+import qualified Data.Witherable as W
200+import Reflex.FunctorMaybe (FunctorMaybe)
196−import Reflex.FunctorMaybe
201+import qualified Reflex.FunctorMaybe
197import Reflex.Patch
202import Reflex.Patch
198import qualified Reflex.Patch.MapWithMove as PatchMapWithMove
203import qualified Reflex.Patch.MapWithMove as PatchMapWithMove
199
204
@@ -388,8 +393,8 @@ mapAccumMaybeMIncremental f z e = do
388 return $ case result of
393 return $ case result of
389 (Nothing, Nothing) -> Nothing
394 (Nothing, Nothing) -> Nothing
390 _ -> Just result
395 _ -> Just result
391− d' <- holdIncremental z $ fmapMaybe fst e'
396+ d' <- holdIncremental z $ mapMaybe fst e'
392− return (d', fmapMaybe snd e')
397+ return (d', mapMaybe snd e')
393
398
394slowHeadE :: (Reflex t, MonadHold t m, MonadFix m) => Event t a -> m (Event t a)
399slowHeadE :: (Reflex t, MonadHold t m, MonadFix m) => Event t a -> m (Event t a)
395slowHeadE e = do
400slowHeadE e = do
@@ -399,14 +404,14 @@ slowHeadE e = do
399
404
400-- | An 'EventSelector' allows you to efficiently 'select' an 'Event' based on a
405-- | An 'EventSelector' allows you to efficiently 'select' an 'Event' based on a
401-- key. This is much more efficient than filtering for each key with
406-- key. This is much more efficient than filtering for each key with
402−-- 'fmapMaybe'.
407+-- 'mapMaybe'.
403newtype EventSelector t k = EventSelector
408newtype EventSelector t k = EventSelector
404 { -- | Retrieve the 'Event' for the given key. The type of the 'Event' is
409 { -- | Retrieve the 'Event' for the given key. The type of the 'Event' is
405 -- determined by the type of the key, so this can be used to fan-out
410 -- determined by the type of the key, so this can be used to fan-out
406 -- 'Event's whose sub-'Event's have different types.
411 -- 'Event's whose sub-'Event's have different types.
407 --
412 --
408 -- Using 'EventSelector's and the 'fan' primitive is far more efficient than
413 -- Using 'EventSelector's and the 'fan' primitive is far more efficient than
409− -- (but equivalent to) using 'fmapMaybe' to select only the relevant
414+ -- (but equivalent to) using 'mapMaybe' to select only the relevant
410 -- occurrences of an 'Event'.
415 -- occurrences of an 'Event'.
411 select :: forall a. k a -> Event t a
416 select :: forall a. k a -> Event t a
412 }
417 }
@@ -550,22 +555,25 @@ instance (Reflex t, Semigroup a) => Semigroup (Behavior t a) where
550 times1p n = fmap $ times1p n
555 times1p n = fmap $ times1p n
551#endif
556#endif
552
557
558+-- | Alias for 'mapMaybe'
559+fmapMaybe :: Filterable f => (a -> Maybe b) -> f a -> f b
560+fmapMaybe = mapMaybe
561+
553−-- | Flipped version of 'fmapMaybe'.
562+-- | Flipped version of 'mapMaybe'.
554−fforMaybe :: FunctorMaybe f => f a -> (a -> Maybe b) -> f b
563+fforMaybe :: Filterable f => f a -> (a -> Maybe b) -> f b
555−fforMaybe = flip fmapMaybe
564+fforMaybe = flip mapMaybe
556
565
557-- | Filter 'f a' using the provided predicate.
566-- | Filter 'f a' using the provided predicate.
558−-- Relies on 'fforMaybe'.
559−ffilter :: FunctorMaybe f => (a -> Bool) -> f a -> f a
567+ffilter :: Filterable f => (a -> Bool) -> f a -> f a
560−ffilter f = fmapMaybe $ \x -> if f x then Just x else Nothing
568+ffilter = W.filter
561
569
562-- | Filter 'Left's from 'f (Either a b)' into 'a'.
570-- | Filter 'Left's from 'f (Either a b)' into 'a'.
563−filterLeft :: FunctorMaybe f => f (Either a b) -> f a
571+filterLeft :: Filterable f => f (Either a b) -> f a
564−filterLeft = fmapMaybe (either Just (const Nothing))
572+filterLeft = mapMaybe (either Just (const Nothing))
565
573
566-- | Filter 'Right's from 'f (Either a b)' into 'b'.
574-- | Filter 'Right's from 'f (Either a b)' into 'b'.
567−filterRight :: FunctorMaybe f => f (Either a b) -> f b
575+filterRight :: Filterable f => f (Either a b) -> f b
568−filterRight = fmapMaybe (either (const Nothing) Just)
576+filterRight = mapMaybe (either (const Nothing) Just)
569
577
570-- | Left-biased event union (prefers left event on simultaneous
578-- | Left-biased event union (prefers left event on simultaneous
571-- occurrence).
579-- occurrence).
@@ -583,13 +591,18 @@ instance Reflex t => Bind (Event t) where
583
591
584instance Reflex t => Functor (Event t) where
592instance Reflex t => Functor (Event t) where
585 {-# INLINE fmap #-}
593 {-# INLINE fmap #-}
586− fmap f = fmapMaybe $ Just . f
594+ fmap f = mapMaybe $ Just . f
587 {-# INLINE (<$) #-}
595 {-# INLINE (<$) #-}
588 x <$ e = fmapCheap (const x) e
596 x <$ e = fmapCheap (const x) e
589
597
598+-- TODO Remove this instance
590instance Reflex t => FunctorMaybe (Event t) where
599instance Reflex t => FunctorMaybe (Event t) where
591 {-# INLINE fmapMaybe #-}
600 {-# INLINE fmapMaybe #-}
601+ fmapMaybe = mapMaybe
602+
603+instance Reflex t => Filterable (Event t) where
604+ {-# INLINE mapMaybe #-}
592− fmapMaybe f = push $ return . f
605+ mapMaybe f = push $ return . f
593
606
594-- | Never: @'zero' = 'never'@.
607-- | Never: @'zero' = 'never'@.
595instance Reflex t => Plus (Event t) where
608instance Reflex t => Plus (Event t) where
@@ -807,7 +820,7 @@ fanEither :: Reflex t => Event t (Either a b) -> (Event t a, Event t b)
807fanEither e =
820fanEither e =
808 let justLeft = either Just (const Nothing)
821 let justLeft = either Just (const Nothing)
809 justRight = either (const Nothing) Just
822 justRight = either (const Nothing) Just
810− in (fmapMaybe justLeft e, fmapMaybe justRight e)
823+ in (mapMaybe justLeft e, mapMaybe justRight e)
811
824
812-- | Split the event into separate events for 'This' and 'That' values,
825-- | Split the event into separate events for 'This' and 'That' values,
813-- allowing them to fire simultaneously when the input value is 'These'.
826-- allowing them to fire simultaneously when the input value is 'These'.
@@ -819,7 +832,7 @@ fanThese e =
819 that (That y) = Just y
832 that (That y) = Just y
820 that (These _ y) = Just y
833 that (These _ y) = Just y
821 that _ = Nothing
834 that _ = Nothing
822− in (fmapMaybe this e, fmapMaybe that e)
835+ in (mapMaybe this e, mapMaybe that e)
823
836
824-- | Split the event into an 'EventSelector' that allows efficient selection of
837-- | Split the event into an 'EventSelector' that allows efficient selection of
825-- the individual 'Event's.
838-- the individual 'Event's.
@@ -1002,9 +1015,11 @@ difference = alignEventWithMaybe $ \case
1002
1015
1003alignEventWithMaybe :: Reflex t => (These a b -> Maybe c) -> Event t a -> Event t b -> Event t c
1016alignEventWithMaybe :: Reflex t => (These a b -> Maybe c) -> Event t a -> Event t b -> Event t c
1004alignEventWithMaybe f ea eb =
1017alignEventWithMaybe f ea eb =
1005− fmapMaybe (f <=< dmapToThese)
1018+ mapMaybe (f <=< dmapToThese)
1006 $ merge
1019 $ merge
1007 $ DMap.fromList [LeftTag :=> ea, RightTag :=> eb]
1020 $ DMap.fromList [LeftTag :=> ea, RightTag :=> eb]
1021+alignEventWithMaybe f ea eb = mapMaybe (f <=< dmapToThese) $
1022+ merge $ DMap.fromList [LeftTag :=> ea, RightTag :=> eb]
1008
1023
1009filterEventKey
1024filterEventKey
1010 :: forall t m k v a.
1025 :: forall t m k v a.
@@ -1100,8 +1115,8 @@ mapAccumMaybeMDyn f z e = do
1100 return $ case result of
1115 return $ case result of
1101 (Nothing, Nothing) -> Nothing
1116 (Nothing, Nothing) -> Nothing
1102 _ -> Just result
1117 _ -> Just result
1103− d' <- holdDyn z $ fmapMaybe fst e'
1118+ d' <- holdDyn z $ mapMaybe fst e'
1104− return (d', fmapMaybe snd e')
1119+ return (d', mapMaybe snd e')
1105
1120
1106{-# INLINE accumB #-}
1121{-# INLINE accumB #-}
1107accumB :: (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> a) -> a -> Event t b -> m (Behavior t a)
1122accumB :: (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> a) -> a -> Event t b -> m (Behavior t a)
@@ -1139,8 +1154,8 @@ mapAccumMaybeMB f z e = do
1139 return $ case result of
1154 return $ case result of
1140 (Nothing, Nothing) -> Nothing
1155 (Nothing, Nothing) -> Nothing
1141 _ -> Just result
1156 _ -> Just result
1142− d' <- hold z $ fmapMaybe fst e'
1157+ d' <- hold z $ mapMaybe fst e'
1143− return (d', fmapMaybe snd e')
1158+ return (d', mapMaybe snd e')
1144
1159
1145-- | Accumulate occurrences of an 'Event', producing an output occurrence each
1160-- | Accumulate occurrences of an 'Event', producing an output occurrence each
1146-- time. Discard the underlying 'Accumulator'.
1161-- time. Discard the underlying 'Accumulator'.
@@ -1288,13 +1303,19 @@ infixl 4 <@
1288pushAlwaysCheap :: Reflex t => (a -> PushM t b) -> Event t a -> Event t b
1303pushAlwaysCheap :: Reflex t => (a -> PushM t b) -> Event t a -> Event t b
1289pushAlwaysCheap f = pushCheap (fmap Just . f)
1304pushAlwaysCheap f = pushCheap (fmap Just . f)
1290
1305
1306+{-# INLINE mapMaybeCheap #-}
1307+mapMaybeCheap :: Reflex t => (a -> Maybe b) -> Event t a -> Event t b
1308+mapMaybeCheap f = pushCheap $ return . f
1309+
1310+-- | An alias for 'mapMaybeCheap'
1291{-# INLINE fmapMaybeCheap #-}
1311{-# INLINE fmapMaybeCheap #-}
1292fmapMaybeCheap :: Reflex t => (a -> Maybe b) -> Event t a -> Event t b
1312fmapMaybeCheap :: Reflex t => (a -> Maybe b) -> Event t a -> Event t b
1293−fmapMaybeCheap f = pushCheap $ return . f
1313+fmapMaybeCheap = mapMaybeCheap
1314+
1294
1315
1295{-# INLINE fforMaybeCheap #-}
1316{-# INLINE fforMaybeCheap #-}
1296fforMaybeCheap :: Reflex t => Event t a -> (a -> Maybe b) -> Event t b
1317fforMaybeCheap :: Reflex t => Event t a -> (a -> Maybe b) -> Event t b
1297−fforMaybeCheap = flip fmapMaybeCheap
1318+fforMaybeCheap = flip mapMaybeCheap
1298
1319
1299{-# INLINE fforCheap #-}
1320{-# INLINE fforCheap #-}
1300fforCheap :: Reflex t => Event t a -> (a -> b) -> Event t b
1321fforCheap :: Reflex t => Event t a -> (a -> b) -> Event t b
src/Reflex/FunctorMaybe.hs+6−19
@@ -9,46 +9,33 @@ module Reflex.FunctorMaybe
9 ) where
9 ) where
10
10
11import Data.IntMap (IntMap)
11import Data.IntMap (IntMap)
12−import qualified Data.IntMap as IntMap
13import Data.Map (Map)
12import Data.Map (Map)
14−import qualified Data.Map as Map
15−import Data.Maybe
16#if MIN_VERSION_base(4,9,0)
13#if MIN_VERSION_base(4,9,0)
17import Data.Semigroup (Option(..))
14import Data.Semigroup (Option(..))
18#endif
15#endif
16+import Data.Witherable
19
17
20--TODO: See if there's a better class in the standard libraries already
18--TODO: See if there's a better class in the standard libraries already
21
19
22-- | A class for values that combines filtering and mapping using 'Maybe'.
20-- | A class for values that combines filtering and mapping using 'Maybe'.
23−-- Morally, @'FunctorMaybe' ~ KleisliFunctor 'Maybe'@. Also similar is the
21+-- Morally, @'FunctorMaybe' ~ KleisliFunctor 'Maybe'@.
24−-- @Witherable@ typeclass, but it requires @'Foldable' f@ and @'Traversable' f@,
22+{-# DEPRECATED FunctorMaybe "Use 'Filterable' from Data.Witherable instead" #-}
25−-- and e.g. 'Event' is instance of neither.
26−--
27−-- A definition of 'fmapMaybe' must satisfy the following laws:
28−--
29−-- [/identity/]
30−-- @'fmapMaybe' 'Just' ≡ 'id'@
31−--
32−-- [/composition/]
33−-- @'fmapMaybe' (f <=< g) ≡ 'fmapMaybe' f . 'fmapMaybe' g@
34class FunctorMaybe f where
23class FunctorMaybe f where
35 -- | Combined mapping and filtering function.
24 -- | Combined mapping and filtering function.
36 fmapMaybe :: (a -> Maybe b) -> f a -> f b
25 fmapMaybe :: (a -> Maybe b) -> f a -> f b
37
26
38−-- | @fmapMaybe = (=<<)
39instance FunctorMaybe Maybe where
27instance FunctorMaybe Maybe where
40− fmapMaybe = (=<<)
28+ fmapMaybe = mapMaybe
41
29
42#if MIN_VERSION_base(4,9,0)
30#if MIN_VERSION_base(4,9,0)
43deriving instance FunctorMaybe Option
31deriving instance FunctorMaybe Option
44#endif
32#endif
45
33
46−-- | @fmapMaybe = mapMaybe@
47instance FunctorMaybe [] where
34instance FunctorMaybe [] where
48 fmapMaybe = mapMaybe
35 fmapMaybe = mapMaybe
49
36
50instance FunctorMaybe (Map k) where
37instance FunctorMaybe (Map k) where
51− fmapMaybe = Map.mapMaybe
38+ fmapMaybe = mapMaybe
52
39
53instance FunctorMaybe IntMap where
40instance FunctorMaybe IntMap where
54− fmapMaybe = IntMap.mapMaybe
41+ fmapMaybe = mapMaybe
src/Reflex/Requester/Base.hs+2−2
@@ -378,7 +378,7 @@ traverseIntMapWithKeyWithAdjustRequesterTWith base patchNewElements mergePatchIn
378 pack = Entry
378 pack = Entry
379 f' :: IntMap.Key -> (Int, v) -> m (Event t (IntMap (RequesterData request)), v')
379 f' :: IntMap.Key -> (Int, v) -> m (Event t (IntMap (RequesterData request)), v')
380 f' k (n, v) = do
380 f' k (n, v) = do
381− (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?
381+ (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?
382 return (fmapCheap (IntMap.singleton n) myRequests, result)
382 return (fmapCheap (IntMap.singleton n) myRequests, result)
383 ndm' <- numberOccurrencesFrom 1 dm'
383 ndm' <- numberOccurrencesFrom 1 dm'
384 (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
384 (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
@@ -426,7 +426,7 @@ traverseDMapWithKeyWithAdjustRequesterTWith base mapPatch weakenPatchWith patchN
426 pack = Entry
426 pack = Entry
427 f' :: forall a. k a -> Compose ((,) Int) v a -> m (Compose ((,) (Event t (IntMap (RequesterData request)))) v' a)
427 f' :: forall a. k a -> Compose ((,) Int) v a -> m (Compose ((,) (Event t (IntMap (RequesterData request)))) v' a)
428 f' k (Compose (n, v)) = do
428 f' k (Compose (n, v)) = do
429− (result, myRequests) <- runRequesterT (f k v) $ fmapMaybeCheap (IntMap.lookup n) $ select responses (Const2 (Some.This k))
429+ (result, myRequests) <- runRequesterT (f k v) $ mapMaybeCheap (IntMap.lookup n) $ select responses (Const2 (Some.This k))
430 return $ Compose (fmapCheap (IntMap.singleton n) myRequests, result)
430 return $ Compose (fmapCheap (IntMap.singleton n) myRequests, result)
431 ndm' <- numberOccurrencesFrom 1 dm'
431 ndm' <- numberOccurrencesFrom 1 dm'
432 (children0, children') <- base f' (DMap.map (\v -> Compose (0, v)) dm0) $ fmap (\(n, dm) -> mapPatch (\v -> Compose (n, v)) dm) ndm'
432 (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)
src/Reflex/Time.hs+1−1
@@ -28,7 +28,7 @@ import Control.Monad.IO.Class
28import Data.Align
28import Data.Align
29import Data.Data (Data)
29import Data.Data (Data)
30import Data.Fixed
30import Data.Fixed
31−import Data.Semigroup
31+import Data.Semigroup ((<>))
32import Data.Sequence (Seq, (|>))
32import Data.Sequence (Seq, (|>))
33import qualified Data.Sequence as Seq
33import qualified Data.Sequence as Seq
34import Data.These
34import Data.These