3 ms·
It'd help beginners if there was a sentence explaining what fmap is.
by iamwil 10y ago
It'd help beginners if there was a sentence explaining what fmap is.
- m-j-fox 10y agoOr morphism.
- hzjavier 10y agoAgree. Also, order can improve. You talk about pure functions on the first sentence. Later you explain what a pure function is. Explaining pure functions before monads can help. Same case for functors.
- chrisdone 10y agoIn 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.