4 ms·
You might be misunderstanding functors since they are basically tangential to classes. Every generic class `F<T>` where we can lift functions `T -> S` to `F<T>
by Tarean 10y ago
You might be misunderstanding functors since they are basically tangential to classes. Every generic class `F<T>` where we can lift functions `T -> S` to `F<T> -> F<S>` is a functor.
Think of lists as example, they are generic over a type and we can apply functions over the base type by applying them to each element.
Functors are a basic building block of category theory. Category theory is basically the essence of composition so using functors leads to easy to reason about and extremely composable code. This also extends to things that build on functors like monads.
- pseudonom- 10y agoML uses "functors" in a different sense than e.g. Haskell.
- saosebastiao 10y agoIn ML a functor is a very different thing from Haskell. It is akin to a higher order module. http://stackoverflow.com/a/16353711 http://stackoverflow.com/a/16353711