Copyright | (c) 2006-2007 Roman Leshchinskiy (c) 2013 Simon Meier |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | Simon Meier <iridcode@gmail.com> |
Stability | experimental |
Portability | GHC |
Safe Haskell | None |
Language | Haskell2010 |
The strict variant of the standard Haskell Maybe
type and the
corresponding variants of the functions from Data.Maybe.
Note that in contrast to the standard lazy Maybe
type, the strict
Maybe
type is not an applicative functor, and therefore also not a monad.
The problem is the homomorphism law, which states that
pure
f<*>
pure
x =pure
(f x) -- must hold for all f
This law does not hold for the expected applicative functor instance of
Maybe
, as this instance does not satisfy pure f <*> pure _|_ = pure (f
_|_)
for f = const
.
Synopsis
- data Maybe a
- maybe :: b -> (a -> b) -> Maybe a -> b
- isJust :: Maybe a -> Bool
- isNothing :: Maybe a -> Bool
- fromJust :: Maybe a -> a
- fromMaybe :: a -> Maybe a -> a
- listToMaybe :: [a] -> Maybe a
- maybeToList :: Maybe a -> [a]
- catMaybes :: [Maybe a] -> [a]
- mapMaybe :: (a -> Maybe b) -> [a] -> [b]
- _Just :: Prism (Maybe a) (Maybe b) a b
- _Nothing :: Prism' (Maybe a) ()
Documentation
The type of strict optional values.
Instances
Functor Maybe | |
Foldable Maybe | |
Defined in Data.Strict.Maybe fold :: Monoid m => Maybe m -> m # foldMap :: Monoid m => (a -> m) -> Maybe a -> m # foldr :: (a -> b -> b) -> b -> Maybe a -> b # foldr' :: (a -> b -> b) -> b -> Maybe a -> b # foldl :: (b -> a -> b) -> b -> Maybe a -> b # foldl' :: (b -> a -> b) -> b -> Maybe a -> b # foldr1 :: (a -> a -> a) -> Maybe a -> a # foldl1 :: (a -> a -> a) -> Maybe a -> a # elem :: Eq a => a -> Maybe a -> Bool # maximum :: Ord a => Maybe a -> a # minimum :: Ord a => Maybe a -> a # | |
Traversable Maybe | |
Eq1 Maybe | |
Ord1 Maybe | |
Defined in Data.Strict.Maybe | |
Read1 Maybe | |
Defined in Data.Strict.Maybe | |
Show1 Maybe | |
NFData1 Maybe | |
Defined in Data.Strict.Maybe | |
Hashable1 Maybe | |
Defined in Data.Strict.Maybe | |
Eq a => Eq (Maybe a) | |
Data a => Data (Maybe a) | |
Defined in Data.Strict.Maybe gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Maybe a -> c (Maybe a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Maybe a) # toConstr :: Maybe a -> Constr # dataTypeOf :: Maybe a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe0 (c (Maybe a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe0 (c (Maybe a)) # gmapT :: (forall b. Data b => b -> b) -> Maybe a -> Maybe a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Maybe a -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Maybe a -> r # gmapQ :: (forall d. Data d => d -> u) -> Maybe a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Maybe a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Maybe a -> m (Maybe a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Maybe a -> m (Maybe a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Maybe a -> m (Maybe a) # | |
Ord a => Ord (Maybe a) | |
Read a => Read (Maybe a) | |
Show a => Show (Maybe a) | |
Generic (Maybe a) | |
Semigroup a => Semigroup (Maybe a) | |
Semigroup a => Monoid (Maybe a) | |
Hashable a => Hashable (Maybe a) | |
Defined in Data.Strict.Maybe | |
Binary a => Binary (Maybe a) | |
NFData a => NFData (Maybe a) | |
Defined in Data.Strict.Maybe | |
Generic1 Maybe | |
type Rep (Maybe a) | |
Defined in Data.Strict.Maybe type Rep (Maybe a) = D1 (MetaData "Maybe" "Data.Strict.Maybe" "strict-0.4-DcORXBfkCIx3v5lLd1UYRe" False) (C1 (MetaCons "Nothing" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "Just" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 a))) | |
type Rep1 Maybe | |
Defined in Data.Strict.Maybe |
listToMaybe :: [a] -> Maybe a #
Analogous to listToMaybe
in Data.Maybe.
maybeToList :: Maybe a -> [a] #
Analogous to maybeToList
in Data.Maybe.
catMaybes :: [Maybe a] -> [a] #
Analogous to catMaybes
in Data.Maybe.
mapMaybe :: (a -> Maybe b) -> [a] -> [b] #
Analogous to mapMaybe
in Data.Maybe.