Safe Haskell | Safe |
---|
Eta.Types.Maybe
Description
Documentation
Instances
Monad Maybe | |
Functor Maybe | |
Applicative Maybe | |
Foldable Maybe | |
Traversable Maybe | |
Generic1 Maybe | |
MonadPlus Maybe | |
Alternative Maybe | |
Eq a => Eq (Maybe a) | |
Ord a => Ord (Maybe a) | |
Read a => Read (Maybe a) | |
Show a => Show (Maybe a) | |
Generic (Maybe a) | |
Monoid a => Monoid (Maybe a) | |
SingKind a (KProxy a) => SingKind (Maybe a) (KProxy (Maybe a)) | |
SingI (Maybe a) (Nothing a) | |
SingI a a1 => SingI (Maybe a) (Just a a1) | |
type Rep1 Maybe | |
type Rep (Maybe a) | |
data Sing (Maybe a) | |
type (==) (Maybe k) a b | |
type DemoteRep (Maybe a) (KProxy (Maybe a)) | |
Returns True
if the Maybe is a Just
Returns True
if the Maybe is a Nothing
>>>
import Eta.Classes.Show
>>>
import Eta.Classes.Monoid
unsafeGetValue :: Maybe a -> a #
handleMaybe :: b -> (a -> b) -> Maybe a -> b #
Handler for the Maybe
type
Takes a default value, a function and a
Maybe
value. If the Maybe is Nothing
,
it returns the default value, otherwise,
it maps the function and returns the
result
>>>
myMaybe = Just 42
>>>
handleMaybe "Nothing found" (\x -> "Got: " <+> show x) myMaybe
"Got: 42"
>>>
myMaybe' = Nothing
>>>
handleMaybe "Nothing found" (\x -> "Got: " <+> show x) myMaybe'
"Nothing found"
onlyJustValues :: [Maybe a] -> [a] #
Discards all Nothing
s from the list,
returning all values
>>>
onlyJustValues [Just 1, Nothing, Just 2]
[1,2]