File tree Expand file tree Collapse file tree 1 file changed +3
-0
lines changed
core/src/main/scala/sttp/monad Expand file tree Collapse file tree 1 file changed +3
-0
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,8 @@ trait MonadError[F[_]] {
34
34
def suspend [T ](t : => F [T ]): F [T ] = flatten(eval(t))
35
35
def flatten [T ](ffa : F [F [T ]]): F [T ] = flatMap[F [T ], T ](ffa)(identity)
36
36
37
+ def flatTap [T , U ](fa : F [T ])(f : T => F [U ]): F [T ] = flatMap(fa)(t => map(f(t))(_ => t))
38
+
37
39
def fromTry [T ](t : Try [T ]): F [T ] =
38
40
t match {
39
41
case Success (v) => unit(v)
@@ -55,6 +57,7 @@ object syntax {
55
57
def flatMap [B ](f : A => F [B ])(implicit ME : MonadError [F ]): F [B ] = ME .flatMap(r)(f)
56
58
def handleError [T ](h : PartialFunction [Throwable , F [A ]])(implicit ME : MonadError [F ]): F [A ] = ME .handleError(r)(h)
57
59
def ensure (e : => F [Unit ])(implicit ME : MonadError [F ]): F [A ] = ME .ensure(r, e)
60
+ def flatTap [B ](f : A => F [B ])(implicit ME : MonadError [F ]): F [A ] = ME .flatTap(r)(f)
58
61
}
59
62
60
63
implicit final class MonadErrorValueOps [F [_], A ](private val v : A ) extends AnyVal {
You can’t perform that action at this time.
0 commit comments