3 ms·
In Haskell and PureScript, `fmap` is a method in the `Functor` class, which is defined by class Functor f where fmap :: (a -> b) -> f a -> f b for wh
by chrisdone 10y ago
In Haskell and PureScript, `fmap` is a method in the `Functor` class, which is defined by
class Functor f where
fmap :: (a -> b) -> f a -> f b
for which instances should satisfy `fmap id = id` (and you get `fmap (g . f) = fmap g . fmap f` for free). If you can find a type for which you can implement `fmap` and satisfy the laws, then you have an instance of `Functor`.
That's the precise and short definition. It assumes the following knowledge:
0. How partial application works and the . works.
1. How Haskell's type-classes work (`Functor`).
2. How Haskell's methods work (`fmap`).
3. How Haskell's higher-kinded types work (the `f`).
So good luck explaining `fmap` in one sentence unless you already know Haskell and understand its type system to a confident degree, which depending on your background can take weeks to months.
- iamwil 10y agoThere's often no need to explain everything in detail to get the gist.