diff options
author | Sam Guymer <sam@guymer.me> | 2018-05-17 20:11:22 +1000 |
---|---|---|
committer | Sam Guymer <sam@guymer.me> | 2018-05-19 00:37:52 +1000 |
commit | 92e10991df0d168d1972d4618fcc7e02e2e0a0fa (patch) | |
tree | 14e0d112fd47856a8c87ad1782d51a928b01bbf6 /core/src/main/scala/com/softwaremill/sttp/MonadError.scala | |
parent | 588395d018c258eb74f60ad95bad706698bdf915 (diff) | |
download | sttp-92e10991df0d168d1972d4618fcc7e02e2e0a0fa.tar.gz sttp-92e10991df0d168d1972d4618fcc7e02e2e0a0fa.tar.bz2 sttp-92e10991df0d168d1972d4618fcc7e02e2e0a0fa.zip |
Move backend tests into their projects
Instead of having a single project which tests all backends, each
backend now implements a http test trait along with a streaming test
trait if it supports streaming. The test http server has been moved into
its own project and is started automatically before running a backends
test. This allows each backend to be tested without the possibility of
dependency eviction from another backend or the test http server. It
also has the side effect of parallelizing the tests providing a speed
up when run with multiple cores.
Diffstat (limited to 'core/src/main/scala/com/softwaremill/sttp/MonadError.scala')
-rw-r--r-- | core/src/main/scala/com/softwaremill/sttp/MonadError.scala | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/core/src/main/scala/com/softwaremill/sttp/MonadError.scala b/core/src/main/scala/com/softwaremill/sttp/MonadError.scala index a783765..b5b1852 100644 --- a/core/src/main/scala/com/softwaremill/sttp/MonadError.scala +++ b/core/src/main/scala/com/softwaremill/sttp/MonadError.scala @@ -31,6 +31,15 @@ trait MonadAsyncError[R[_]] extends MonadError[R] { def async[T](register: (Either[Throwable, T] => Unit) => Unit): R[T] } +object syntax { + + implicit final class MonadErrorOps[R[_], A](val r: R[A]) extends AnyVal { + def map[B](f: A => B)(implicit ME: MonadError[R]): R[B] = ME.map(r)(f) + def flatMap[B](f: A => R[B])(implicit ME: MonadError[R]): R[B] = + ME.flatMap(r)(f) + } +} + object IdMonad extends MonadError[Id] { override def unit[T](t: T): Id[T] = t override def map[T, T2](fa: Id[T])(f: (T) => T2): Id[T2] = f(fa) |