This file contains hidden or 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
trait SomeTrait { | |
def fetchAll: Future[Seq[String]] | |
} |
This file contains hidden or 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
implicit class ListOp[A](lst: List[A]) { | |
def filterBy(p: A => Predicate): List[A] = lst.filter{ p(_) match { | |
case Predicate.Keep => true | |
case Predicate.Discard => false | |
} | |
} | |
} |
This file contains hidden or 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
List(1,2,4).filter{p => if(p > 2) Predicate.Keep else Predicate.Disacrd} |
This file contains hidden or 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
def filter[A](p: A => Predicate): List[A] |
This file contains hidden or 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
sealed trait Predicate | |
object Predicate { | |
case object Keep extends Predicate | |
case object Discard extends Predicate | |
} |
This file contains hidden or 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
trait List[A] { | |
def filter(p : A => Boolean): List[A] | |
} |
This file contains hidden or 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
trait SomeInterface { | |
def someFunction(): Future[Either[Throwable, String]] | |
} |
This file contains hidden or 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
trait SomeInterface { | |
def someFunction(): EitherT[Future, Throwable, String] | |
} |
This file contains hidden or 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
def doSomething(res: Future[Either[Throwable, Option[A]]]) = res match { | |
case Success(a) => | |
a match { | |
case Left(ex) => | |
case Right(b) => b match { | |
case Some(c) => | |
case None => | |
} | |
} |
This file contains hidden or 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
def buildRunner | |
((req,Resp) => ctx.TransactionContext) | |
((resp, ctx.rtx.Transaction) => Final[Context]) | |
(resp => Unit): Runner[ctx.Transaction, rtx.TransacitonResponse] = new Runner[ctx.Transaction, rtx.TransactionResponse] { | |
override def run((ctx.Transaction, rtx.TransactionResponse) => Response): Req => Resp = ??? | |
} | |
trait Runner[T, F] { | |
def run((T,F) => Response): Req => Resp |
NewerOlder