850 B
850 B
Functor
In Software Development, this refers to a parameterized data type that wraps a value in a context and provides a method for applying a function to the wrapped value, independent of the container type.
In Haskell, the function for applying a function to a value in a functor is
fmap
, also available as the infix operator <$>
.
fmap :: Functor f => (a -> b) -> f a -> f b
fmap
in Haskell
Examples
Maybe
instance Functor Maybe where
fmap func (Just n) = Just (func n)
fmap func Nothing = Nothing