-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
132 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
modules/core/src/main/scala/sangria/execution/EffectScheme.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package sangria.execution | ||
|
||
import scala.concurrent.{ExecutionContext, Future} | ||
|
||
trait EffectScheme { | ||
type F[_] | ||
def map[A, B](eff: F[A])(f: A => B): F[B] | ||
def flatMap[A, B](eff: F[A])(f: A => F[B]): F[B] | ||
def success[A](a: A): F[A] | ||
def fromFuture[A](f: Future[A]): F[A] | ||
def toFuture[A](f: F[A]): Future[A] | ||
} | ||
|
||
class FutureEffectScheme(implicit ec: ExecutionContext) extends EffectScheme { | ||
override type F[A] = Future[A] | ||
|
||
override def map[A, B](eff: Future[A])(f: A => B): Future[B] = eff.map(f) | ||
override def flatMap[A, B](eff: Future[A])(f: A => Future[B]): Future[B] = eff.flatMap(f) | ||
override def success[A](a: A): Future[A] = Future.successful(a) | ||
override def fromFuture[A](f: Future[A]): Future[A] = f | ||
override def toFuture[A](f: Future[A]): Future[A] = f | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters