Skip to content

Instantly share code, notes, and snippets.

@okapies
Last active December 26, 2015 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save okapies/7182102 to your computer and use it in GitHub Desktop.
Save okapies/7182102 to your computer and use it in GitHub Desktop.
Value type as Sum types
// 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