Skip to content

Reader : functional dependency injection

johnmcclean-aol edited this page Nov 22, 2016 · 3 revisions

Reader monad

The Reader class allows us to transform functions, by composing them.

E.g given two functions, one that maps from T to R and another from R to R1..

Function<T, R> fn;
Function<? super R, ? extends R1> fn2;

We can combine them to create a single function that maps from T to R1

Function<T,R1> composed = fn.andThen(fn2)

Clone this wiki locally