You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm thinking whether it makes sense to add monadic versions of scanLeftNe* and scanRightNe* functions similar to groupByNe*A (which would complement regular groupByNe*)? For example, for scanLeftNeSeq there could be
def scanLeftNeSeqM[F[_], B](b: B)(f: (B, A) => F[B])(implicit F: Monad[F]): F[NonEmptySeq[B]] = {
val nesTraversable = Traverse[NonEmptySeq]
nesTraversable.sequence(scanLeftNeSeq(F.pure(b)) { (fb, a) =>
F.flatMap(fb) { f(_, a) }
})
}
It is -M because I didn't manage to come up with how to avoid flat-mapping in the inner f therefore F[_] has to be a Monad instead of just Applicative.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Copied from the Discord channel.
I'm thinking whether it makes sense to add monadic versions of
scanLeftNe*
andscanRightNe*
functions similar togroupByNe*A
(which would complement regulargroupByNe*
)? For example, forscanLeftNeSeq
there could beIt is
-M
because I didn't manage to come up with how to avoid flat-mapping in the innerf
thereforeF[_]
has to be aMonad
instead of justApplicative
.Beta Was this translation helpful? Give feedback.
All reactions