Skip to content

Instantly share code, notes, and snippets.

@non
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save non/aba13319c097bced2fb9 to your computer and use it in GitHub Desktop.
Save non/aba13319c097bced2fb9 to your computer and use it in GitHub Desktop.
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