Created
July 13, 2017 06:32
-
-
Save anonymous/5ff8cf1f4b799b27d95bced39cbb218d to your computer and use it in GitHub Desktop.
the description for this gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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