Skip to content

Instantly share code, notes, and snippets.

Created July 13, 2017 06:32
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 anonymous/5ff8cf1f4b799b27d95bced39cbb218d to your computer and use it in GitHub Desktop.
Save anonymous/5ff8cf1f4b799b27d95bced39cbb218d to your computer and use it in GitHub Desktop.
the description for this gist
trait handlersId {
implicit val basicMathHandler = new BasicMath.Handler[Id] {
def add(a: Int, b: Int): Id[Int] = a + b
def subtract(a: Int, b: Int): Id[Int] = a - b
def multiply(a: Int, b: Int): Id[Int] = a * b
}
implicit val highMathHandler = new HighMath.Handler[Id] {
def power(a: Int, b: Int): Id[Int] =
(0 until b).fold(1)((acc, _) => acc * a)
}
}
object handlersId extends handlersId
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment