Package com.jnape.palatable.lambda.monad
Interface MonadWriter<W,A,MW extends MonadWriter<W,?,MW>>
-
- Type Parameters:
W
- the accumulation typeA
- the output typeMW
- the witness
- All Superinterfaces:
Applicative<A,MW>
,Functor<A,MW>
,Monad<A,MW>
- 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
,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
,Tuple2
,Tupler2
,Uncons
,Under
,Unfoldr
,Union
,Until
,Upcast
,View
,Writer
,WriterT
,Xor
,Zip
,ZipWith
public interface MonadWriter<W,A,MW extends MonadWriter<W,?,MW>> extends Monad<A,MW>
AMonad
that is capable of writing and accumulating state alongside a value, but is not necessarily capable of simultaneously accessing the state and the value.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description MonadWriter<W,A,MW>
censor(Fn1<? super W,? extends W> fn)
Update the accumulated state.default <B> MonadWriter<W,B,MW>
discardL(Applicative<B,MW> appB)
Sequence both thisApplicative
andappB
, discarding thisApplicative's
result and returningappB
.default <B> MonadWriter<W,A,MW>
discardR(Applicative<B,MW> appB)
Sequence both thisApplicative
andappB
, discardingappB's
result and returning thisApplicative
.<B> MonadWriter<W,B,MW>
flatMap(Fn1<? super A,? extends Monad<B,MW>> f)
Chain dependent computations that may continue or short-circuit based on previous results.default <B> MonadWriter<W,B,MW>
fmap(Fn1<? super A,? extends B> fn)
Covariantly transmute this functor's parameter using the given mapping function.default <B> Lazy<? extends MonadWriter<W,B,MW>>
lazyZip(Lazy<? extends Applicative<Fn1<? super A,? extends B>,MW>> lazyAppFn)
Given alazy
instance of this applicative over a mapping function, "zip" the two instances together using whatever application semantics the current applicative supports.<B> MonadWriter<W,Tuple2<A,B>,MW>
listens(Fn1<? super W,? extends B> fn)
Map the accumulation into a value and pair it with the current output.<B> MonadWriter<W,B,MW>
pure(B b)
Lift the valueb
into this applicative functor.default <B> MonadWriter<W,B,MW>
zip(Applicative<Fn1<? super A,? extends B>,MW> appFn)
Given another instance of this applicative over a mapping function, "zip" the two instances together using whatever application semantics the current applicative supports.
-
-
-
Method Detail
-
listens
<B> MonadWriter<W,Tuple2<A,B>,MW> listens(Fn1<? super W,? extends B> fn)
Map the accumulation into a value and pair it with the current output.- Type Parameters:
B
- the mapped output- Parameters:
fn
- the mapping function- Returns:
- the updated
MonadWriter
-
censor
MonadWriter<W,A,MW> censor(Fn1<? super W,? extends W> fn)
Update the accumulated state.- Parameters:
fn
- the update function- Returns:
- the updated
MonadWriter
-
flatMap
<B> MonadWriter<W,B,MW> flatMap(Fn1<? super A,? extends Monad<B,MW>> f)
Chain dependent computations that may continue or short-circuit based on previous results.
-
pure
<B> MonadWriter<W,B,MW> pure(B b)
Lift the valueb
into this applicative functor.
-
fmap
default <B> MonadWriter<W,B,MW> 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.
-
zip
default <B> MonadWriter<W,B,MW> zip(Applicative<Fn1<? super A,? extends B>,MW> appFn)
Given another instance of this applicative over a mapping function, "zip" the two instances together using whatever application semantics the current applicative supports.
-
lazyZip
default <B> Lazy<? extends MonadWriter<W,B,MW>> lazyZip(Lazy<? extends Applicative<Fn1<? super A,? extends B>,MW>> lazyAppFn)
Given alazy
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.
-
discardL
default <B> MonadWriter<W,B,MW> discardL(Applicative<B,MW> appB)
Sequence both thisApplicative
andappB
, discarding thisApplicative's
result and returningappB
. This is generally useful for sequentially performing side-effects.
-
discardR
default <B> MonadWriter<W,A,MW> discardR(Applicative<B,MW> appB)
Sequence both thisApplicative
andappB
, discardingappB's
result and returning thisApplicative
. This is generally useful for sequentially performing side-effects.
-
-