F
- The container type.Mu
- The witness type of this functor.public interface Functor<F extends K1,Mu extends Functor _> extends Kind1 F
map(Function, App)
, which transforms the contents of a container
to another type.
In order to be a lawful functor, the implementation of map(Function, App)
must satisfy
the following requirements (==
represents logical equality and not reference equality).
map(identity(), ft) = ft
- Mapping with the identity function yields the input.
map(f.compose(g), ft) = map(f, map(g, ft))
- Mapping can be distributed over function composition.
Functors which do not satisfy these laws are said to be either neutral or chaotic, depending on the degree to which the laws are violated.
Modifier and Type | Method and Description |
---|---|
<T,R> F<R> |
map((? super T) -> ? extends R func,
F<T> ts)
Maps the contents of
ts from T to R using the func . |
<T,R> F<R> map((? super T) -> ? extends R func, F<T> ts)
ts
from T
to R
using the func
.T
- The input type.R
- The output type.func
- The transformation function.ts
- The input container that will be transformed.