1-- | This module defines the FunctorMaybe class, which extends Functors with the
2-- ability to delete values.
3module Reflex.FunctorMaybe
7import Data.IntMap (IntMap)
8import qualified Data.IntMap as IntMap
10import qualified Data.Map as Map
13--TODO: See if there's a better class in the standard libraries already
15-- | A class for values that combines filtering and mapping using 'Maybe'.
16-- Morally, @'FunctorMaybe' ~ KleisliFunctor 'Maybe'@. Also similar is the
17-- @Witherable@ typeclass, but it requires @Foldable f@ and @Traverable f@,
18-- and e.g. 'Event' is instance of neither.
20-- A definition of 'fmapMaybe' must satisfy the following laws:
23-- @'fmapMaybe' 'Just' ≡ 'id'@
26-- @'fmapMaybe' (f <=< g) ≡ 'fmapMaybe' f . 'fmapMaybe' g@
27class FunctorMaybe f where
28 -- | Combined mapping and filtering function.
29 fmapMaybe :: (a -> Maybe b) -> f a -> f b
31-- | @fmapMaybe = (=<<)
32instance FunctorMaybe Maybe where
35-- | @fmapMaybe = mapMaybe@
36instance FunctorMaybe [] where
39instance FunctorMaybe (Map k) where
40 fmapMaybe = Map.mapMaybe
42instance FunctorMaybe IntMap where
43 fmapMaybe = IntMap.mapMaybe
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list