Skip to content

Instantly share code, notes, and snippets.

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