@@ -1,3 +1,7 @@
1+{-# LANGUAGE CPP #-}
2+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
3+{-# LANGUAGE StandaloneDeriving #-}
4+
15-- | This module defines the FunctorMaybe class, which extends Functors with the
26-- ability to delete values.
37module Reflex.FunctorMaybe
@@ -9,12 +13,15 @@ import qualified Data.IntMap as IntMap
913import Data.Map (Map)
1014import qualified Data.Map as Map
1115import Data.Maybe
16+#if MIN_VERSION_base(4,9,0)
17+import Data.Semigroup (Option(..))
18+#endif
1219
1320--TODO: See if there's a better class in the standard libraries already
1421
1522-- | A class for values that combines filtering and mapping using 'Maybe'.
1623-- Morally, @'FunctorMaybe' ~ KleisliFunctor 'Maybe'@. Also similar is the
17−-- @Witherable@ typeclass, but it requires @Foldable f@ and @Traverable f@,
24+-- @Witherable@ typeclass, but it requires @'Foldable' f@ and @'Traversable' f@,
1825-- and e.g. 'Event' is instance of neither.
1926--
2027-- A definition of 'fmapMaybe' must satisfy the following laws:
@@ -32,6 +39,10 @@ class FunctorMaybe f where
3239instance FunctorMaybe Maybe where
3340 fmapMaybe = (=<<)
3441
42+#if MIN_VERSION_base(4,9,0)
43+deriving instance FunctorMaybe Option
44+#endif
45+
3546-- | @fmapMaybe = mapMaybe@
3647instance FunctorMaybe [] where
3748 fmapMaybe = mapMaybe