Skip to content

Type Interfaces : Functor

johnmcclean-aol edited this page Nov 22, 2016 · 1 revision

The Functor interface

A Functor can transform data from one type to another. For example we could transform a List of Integers to a List of Strings.

In cyclops-react it has the following methods

  • map : transforms the data using the provided transformation Function
  • peek : allows us to consume the current elements without transforming them (e.g. to print to the console)
  • trampoline : transforms the data using a trampoline for stack-less recursion
  • cast : cast elements from one type to another

Example

Maybe.just(10)
     .map(i->i*2) //convert to 20
     .peek(System.ou::println) //print 20 console when executed

Implementations

CollectionXImpl, CompletableFutureTSeq, CompletableFutureTValue, DequeXImpl, Eval.Module.Always, Eval.Module.Later, EvalTSeq, EvalTValue, FeatureToggle.Disabled, FeatureToggle.Enabled, FluentFunctions.FluentFunction, FunctorWrapper, FutureW, FutureWTSeq, FutureWTValue, Ior.Both, Ior.Primary, Ior.Secondary, LazyImmutable, ListTSeq, ListTValue, ListXImpl, MapXImpl, Maybe.Just, Maybe.Lazy, Maybe.Nothing, MaybeTSeq, MaybeTValue, OptionalTSeq, OptionalTValue, PBagXImpl, PMapXImpl, POrderedSetXImpl, PQueueXImpl, PSetXImpl, PStackXImpl, PVectorXImpl, QueueXImpl, SetTSeq, SetTValue, SetXImpl, SortedSetXImpl, StreamableTSeq, StreamableTValue, StreamTSeq, StreamTValue, Try.Failure, Try.Success, TryTSeq, TryTValue, Xor.Primary, Xor.Secondary, XorTSeq, XorTValue

Clone this wiki locally