aboutsummaryrefslogtreecommitdiff
path: root/implementations/scalaz/src/test/scala/com/softwaremill/sttp/impl/scalaz/package.scala
diff options
context:
space:
mode:
authorSam Guymer <sam@guymer.me>2018-05-17 20:07:04 +1000
committerSam Guymer <sam@guymer.me>2018-05-18 22:28:28 +1000
commit40288a1aaddfc27e141771371d69122ce222a8d0 (patch)
tree14177a51769ce42e88ec3d20435abe505b44aac5 /implementations/scalaz/src/test/scala/com/softwaremill/sttp/impl/scalaz/package.scala
parent96ff655f906f2e3f4e9ba906c42e96506f4668b9 (diff)
downloadsttp-40288a1aaddfc27e141771371d69122ce222a8d0.tar.gz
sttp-40288a1aaddfc27e141771371d69122ce222a8d0.tar.bz2
sttp-40288a1aaddfc27e141771371d69122ce222a8d0.zip
Extract MonadAsyncError implementations
Extract MonadAsyncError implementations into their own projects to allow reuse by multiple backends.
Diffstat (limited to 'implementations/scalaz/src/test/scala/com/softwaremill/sttp/impl/scalaz/package.scala')
-rw-r--r--implementations/scalaz/src/test/scala/com/softwaremill/sttp/impl/scalaz/package.scala25
1 files changed, 25 insertions, 0 deletions
diff --git a/implementations/scalaz/src/test/scala/com/softwaremill/sttp/impl/scalaz/package.scala b/implementations/scalaz/src/test/scala/com/softwaremill/sttp/impl/scalaz/package.scala
new file mode 100644
index 0000000..72dbf31
--- /dev/null
+++ b/implementations/scalaz/src/test/scala/com/softwaremill/sttp/impl/scalaz/package.scala
@@ -0,0 +1,25 @@
+package com.softwaremill.sttp.impl
+
+import com.softwaremill.sttp.testing.streaming.ConvertToFuture
+
+import _root_.scalaz.concurrent.Task
+import _root_.scalaz.{-\/, \/-}
+import scala.concurrent.{Future, Promise}
+import scala.util.{Failure, Success}
+
+package object scalaz {
+
+ val convertToFuture: ConvertToFuture[Task] = new ConvertToFuture[Task] {
+ // from https://github.com/Verizon/delorean
+ override def toFuture[T](value: Task[T]): Future[T] = {
+ val p = Promise[T]()
+
+ value.unsafePerformAsync {
+ case \/-(a) => p.complete(Success(a)); ()
+ case -\/(t) => p.complete(Failure(t)); ()
+ }
+
+ p.future
+ }
+ }
+}