Last active
August 29, 2015 14:01
-
-
Save non/aba13319c097bced2fb9 to your computer and use it in GitHub Desktop.
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
sealed trait Order { | |
def price: Int | |
} | |
case class Buy(price: Int) extends Order | |
case class Sell(price: Int) extends Order | |
sealed trait ValidTrade[A <: Order, B <: Order] | |
object Allowed { | |
implicit val buyAndSell = new ValidTrade[Buy, Sell] | |
implicit val sellAndBuy = new ValidTrade[Sell, Buy] | |
} | |
def place[A <: Order, B <: Order](order: A, offers: List[B])(implicit ok: AllowedTrade[A, B]): A = order |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment