val a: Option[Int] = Some(5)
a :: Maybe Int
a = Just 5
val a: Option[Int] = None
a :: Maybe Int
a = Nothing
Some(5).fold(0)(x => x * x)
maybe 0 (\x -> x * x) (Just 5)
Some(5).map(x => x * x)
(\x -> x * x) <$> (Just 5)
<$>
is not Maybe
-specific: <$>
is an infix operator for fmap
. fmap
is defined in terms of Functor and Maybe has an instance of Functor