Interface MonadReader<R,A,MR extends MonadReader<R,?,MR>>

Type Parameters:
R - the environment
A - the output
MR - the witness
All Superinterfaces:
Applicative<A,MR>, Functor<A,MR>, Monad<A,MR>
All Known Subinterfaces:
BiMonoidFactory<A,B,C>, BiPredicate<A,B>, BiSemigroupFactory<A,B,C>, Effect<A>, Fn0<A>, Fn1<A,B>, Fn2<A,B,C>, Fn3<A,B,C,D>, Fn4<A,B,C,D,E>, Fn5<A,B,C,D,E,F>, Fn6<A,B,C,D,E,F,G>, Fn7<A,B,C,D,E,F,G,H>, Fn8<A,B,C,D,E,F,G,H,I>, Kleisli<A,B,M,MB>, Monoid<A>, MonoidFactory<A,B>, Predicate<A>, Semigroup<A>, SemigroupFactory<A,B>
All Known Implementing Classes:
$, Absent, AddAll, All, Alter, And, Any, AutoBracket, Between, Both, Bracket, CartesianProduct, CatMaybes, Clamp, CmpEq, CmpEqBy, CmpEqWith, Coalesce, Collapse, Collapse, Compare, Compose, Compose, Concat, Cons, Constantly, Cycle, Difference, Distinct, Downcast, Drop, DropWhile, Empty, Endo, EndoK, Eq, Filter, Find, First, Flatten, FoldLeft, FoldRight, Force, GroupBy, GT, GTBy, GTE, GTEBy, GTEWith, GTWith, Head, Id, IfThenElse, InGroupsOf, Init, Inits, Intersection, Intersperse, Into, Into1, Into3, Into4, Into5, Into6, Into7, Into8, Iterate, Join, Last, Last, LazyRec, LeftAll, LeftAll, LeftAny, LeftAny, LiftA2, LiftA3, LiftA4, LiftA5, LiftA6, LiftA7, LT, LTBy, LTE, LTEBy, LTEWith, LTWith, Magnetize, MagnetizeBy, Map, Matching, Max, MaxBy, MaxWith, Merge, Merge, MergeHMaps, MergeMaps, Min, MinBy, MinWith, Not, Occurrences, Or, Over, Partition, Peek, Peek2, Pre, PrependAll, Present, PutAll, RateLimit, Re, ReaderT, ReduceLeft, ReduceRight, Repeat, Replicate, Reverse, RightAll, RightAll, RightAny, RightAny, RunAll, RunAll, ScanLeft, Sequence, Set, Size, Slide, Snoc, Sort, SortBy, SortWith, Span, State, StateT, Tail, Tails, Take, TakeWhile, Times, ToArray, ToCollection, ToMap, Trampoline, Trivial, Tupler2, Uncons, Under, Unfoldr, Union, Until, Upcast, View, Xor, Zip, ZipWith

public interface MonadReader<R,A,MR extends MonadReader<R,?,MR>> extends Monad<A,MR>
A monad that is capable of reading an environment R and producing a lifted value A. This is strictly less powerful than an Fn1, loosening the requirement on Contravariant (and therefore Profunctor constraints), so is more generally applicable, offering instead a local(Fn1) mechanism for modifying the environment *after* reading it but before running the effect (as opposed to Contravariant functors which may modify their inputs *before* running their effects, and may therefore alter the input types).
  • Method Summary

    Modifier and Type
    Method
    Description
    default <B> MonadReader<R,B,MR>
    Sequence both this Applicative and appB, discarding this Applicative's result and returning appB.
    default <B> MonadReader<R,A,MR>
    Sequence both this Applicative and appB, discarding appB's result and returning this Applicative.
    <B> MonadReader<R,B,MR>
    flatMap(Fn1<? super A,? extends Monad<B,MR>> f)
    Chain dependent computations that may continue or short-circuit based on previous results.
    default <B> MonadReader<R,B,MR>
    fmap(Fn1<? super A,? extends B> fn)
    Covariantly transmute this functor's parameter using the given mapping function.
    default <B> Lazy<? extends MonadReader<R,B,MR>>
    lazyZip(Lazy<? extends Applicative<Fn1<? super A,? extends B>,MR>> lazyAppFn)
    Given a lazy instance of this applicative over a mapping function, "zip" the two instances together using whatever application semantics the current applicative supports.
    local(Fn1<? super R,? extends R> fn)
    Modify this MonadReader's environment after reading it but before running the effect.
    <B> MonadReader<R,B,MR>
    pure(B b)
    Lift the value b into this applicative functor.
    default <B> MonadReader<R,B,MR>
    zip(Applicative<Fn1<? super A,? extends B>,MR> appFn)
    Given another instance of this applicative over a mapping function, "zip" the two instances together using whatever application semantics the current applicative supports.

    Methods inherited from interface com.jnape.palatable.lambda.functor.Functor

    coerce
  • Method Details

    • local

      MonadReader<R,A,MR> local(Fn1<? super R,? extends R> fn)
      Modify this MonadReader's environment after reading it but before running the effect.
      Parameters:
      fn - the modification function
      Returns:
      the MonadReader with a modified environment
    • flatMap

      <B> MonadReader<R,B,MR> flatMap(Fn1<? super A,? extends Monad<B,MR>> f)
      Chain dependent computations that may continue or short-circuit based on previous results.
      Specified by:
      flatMap in interface Monad<R,A>
      Type Parameters:
      B - the resulting monad parameter type
      Parameters:
      f - the dependent computation over A
      Returns:
      the new monad instance
    • pure

      <B> MonadReader<R,B,MR> pure(B b)
      Lift the value b into this applicative functor.
      Specified by:
      pure in interface Applicative<R,A>
      Specified by:
      pure in interface Monad<R,A>
      Type Parameters:
      B - the type of the returned applicative's parameter
      Parameters:
      b - the value
      Returns:
      an instance of this applicative over b
    • fmap

      default <B> MonadReader<R,B,MR> fmap(Fn1<? super A,? extends B> fn)
      Covariantly transmute this functor's parameter using the given mapping function. Generally this method is specialized to return an instance of the class implementing Functor.
      Specified by:
      fmap in interface Applicative<R,A>
      Specified by:
      fmap in interface Functor<R,A>
      Specified by:
      fmap in interface Monad<R,A>
      Type Parameters:
      B - the new parameter type
      Parameters:
      fn - the mapping function
      Returns:
      a functor over B (the new parameter type)
    • zip

      default <B> MonadReader<R,B,MR> zip(Applicative<Fn1<? super A,? extends B>,MR> appFn)
      Given another instance of this applicative over a mapping function, "zip" the two instances together using whatever application semantics the current applicative supports.
      Specified by:
      zip in interface Applicative<R,A>
      Specified by:
      zip in interface Monad<R,A>
      Type Parameters:
      B - the resulting applicative parameter type
      Parameters:
      appFn - the other applicative instance
      Returns:
      the mapped applicative
    • lazyZip

      default <B> Lazy<? extends MonadReader<R,B,MR>> lazyZip(Lazy<? extends Applicative<Fn1<? super A,? extends B>,MR>> lazyAppFn)
      Given a lazy instance of this applicative over a mapping function, "zip" the two instances together using whatever application semantics the current applicative supports. This is useful for applicatives that support lazy evaluation and early termination.
      Specified by:
      lazyZip in interface Applicative<R,A>
      Specified by:
      lazyZip in interface Monad<R,A>
      Type Parameters:
      B - the resulting applicative parameter type
      Parameters:
      lazyAppFn - the lazy other applicative instance
      Returns:
      the mapped applicative
      See Also:
    • discardL

      default <B> MonadReader<R,B,MR> discardL(Applicative<B,MR> appB)
      Sequence both this Applicative and appB, discarding this Applicative's result and returning appB. This is generally useful for sequentially performing side-effects.
      Specified by:
      discardL in interface Applicative<R,A>
      Specified by:
      discardL in interface Monad<R,A>
      Type Parameters:
      B - the type of the returned Applicative's parameter
      Parameters:
      appB - the other Applicative
      Returns:
      appB
    • discardR

      default <B> MonadReader<R,A,MR> discardR(Applicative<B,MR> appB)
      Sequence both this Applicative and appB, discarding appB's result and returning this Applicative. This is generally useful for sequentially performing side-effects.
      Specified by:
      discardR in interface Applicative<R,A>
      Specified by:
      discardR in interface Monad<R,A>
      Type Parameters:
      B - the type of appB's parameter
      Parameters:
      appB - the other Applicative
      Returns:
      this Applicative