Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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