Last active
December 26, 2015 16:48
-
-
Save okapies/7182102 to your computer and use it in GitHub Desktop.
Value type as Sum types
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
// value class | |
class Param(val i: Int) extends AnyVal | |
implicit def asParam(i: Int) = Param(i) | |
// followings are invalid because `Param` is a final class. | |
case class AnyParam(_i: Int) extends Param(_i) | |
case object ConstantA extends Param(-1) | |
case object ConstantB extends Param(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment