on develop help sign in
Add 'FunctorMaybe Option' instance
e6daabaAlexandre Esteves
src/Reflex/FunctorMaybe.hs+9
@@ -1,3 +1,7 @@
1+{-# LANGUAGE CPP #-}
2+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
3+{-# LANGUAGE StandaloneDeriving #-}
4+
1-- | This module defines the FunctorMaybe class, which extends Functors with the
5-- | This module defines the FunctorMaybe class, which extends Functors with the
2-- ability to delete values.
6-- ability to delete values.
3module Reflex.FunctorMaybe
7module Reflex.FunctorMaybe
@@ -9,6 +13,7 @@ import qualified Data.IntMap as IntMap
9import Data.Map (Map)
13import Data.Map (Map)
10import qualified Data.Map as Map
14import qualified Data.Map as Map
11import Data.Maybe
15import Data.Maybe
16+import Data.Semigroup (Option(..))
12
17
13--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
14
19
@@ -32,6 +37,10 @@ class FunctorMaybe f where
32instance FunctorMaybe Maybe where
37instance FunctorMaybe Maybe where
33 fmapMaybe = (=<<)
38 fmapMaybe = (=<<)
34
39
40+#if MIN_VERSION_base(4,9,0)
41+deriving instance FunctorMaybe Option
42+#endif
43+
35-- | @fmapMaybe = mapMaybe@
44-- | @fmapMaybe = mapMaybe@
36instance FunctorMaybe [] where
45instance FunctorMaybe [] where
37 fmapMaybe = mapMaybe
46 fmapMaybe = mapMaybe