Package at.jku.ssw.fp.sect06_3_4
Class Reader<C,A>
- java.lang.Object
-
- at.jku.ssw.fp.sect06_3_4.Reader<C,A>
-
- Type Parameters:
C
- the type of the contextA
- the type of the value
public class Reader<C,A> extends Object
Class representing Reader monad. A reader monad reads a value from the context and returns a value- Author:
- Herbert Praehofer
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description A
apply(C context)
Applies the reader function to a context.<B> Reader<C,B>
flatMap(Function<? super A,Reader<C,? extends B>> mapper)
Monad operator.static <C,A>
Reader<C,A>of(Function<C,A> fn)
Creates a reader monad from a reader function.
-
-
-
Method Detail
-
of
public static <C,A> Reader<C,A> of(Function<C,A> fn)
Creates a reader monad from a reader function.- Type Parameters:
C
- the type of the contextA
- the type of the value- Parameters:
fn
- the reader function- Returns:
- the reader monad
-
apply
public A apply(C context)
Applies the reader function to a context.- Parameters:
context
- the context- Returns:
- the read value
-
-