Std.Functor

View source →

Functor interface for structures that support fmap.

A functor is any container F that admits a structure-preserving map. Functor is genuinely higher-kinded: its head f has kind Type -> Type, so fmap lifts a function A -> B to F(A) -> F(B). The built-in implementation for List delegates to Std.List.map/2; additional implementations can be declared for user-defined container types.

Examples

cure
use Std.Functor

fmap([1, 2, 3], fn(x) -> x + 10)        # => [11, 12, 13]