Skip to content

Instantly share code, notes, and snippets.

@zeryx
Created October 30, 2019 19:22
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 zeryx/b7ee39de53f24b25e7ebaff96c5f8951 to your computer and use it in GitHub Desktop.
Save zeryx/b7ee39de53f24b25e7ebaff96c5f8951 to your computer and use it in GitHub Desktop.
import scala.reflect.runtime.universe._
import play.api.libs.json._
import scala.util.{Failure, Success, Try}
object AbstractAlgorithm {
trait AbstractAlgorithm[I, O] {
def apply(input: I): Try[O]
def load(): Try[Unit] = Success(())
}
implicit class ReadDetector[I <: AnyVal](related: AbstractAlgorithm[I, _])(implicit read: Reads[I] = Json.reads[I]) {
implicit def reads: Reads[I] = read
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment