Skip to content

Instantly share code, notes, and snippets.

@kareblak
Last active December 13, 2015 20:48
Show Gist options
  • Save kareblak/4972197 to your computer and use it in GitHub Desktop.
Save kareblak/4972197 to your computer and use it in GitHub Desktop.
trait JsonParser extends BodyParserModule {
def parse[String, O <: Parsable[O]](a: String): O = a match {
case O(o) => o
case _ => ???
}
}
sealed trait Parsable[A] {
def parse(a: String): A
def unapply(a: String): A
}
case class AbvCalc(fg: Double, og: Double) extends Parsable[AbvCalc] {
def parse(a: String): AbvCalc = ???
def unapply(a: String): Option[AbvCalc] = ???
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment