Skip to content

Instantly share code, notes, and snippets.

@paulp
Created May 24, 2010 19:41
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 paulp/412330 to your computer and use it in GitHub Desktop.
Save paulp/412330 to your computer and use it in GitHub Desktop.
sealed abstract class weak_<:<[-From, +To] extends (From => To)
implicit val weakByteChar = new weak_<:<[Byte, Char] { def apply(x: Byte): Char = x.toChar }
implicit val weakByteShort = new weak_<:<[Byte, Short] { def apply(x: Byte): Short = x.toShort }
implicit val weakByteInt = new weak_<:<[Byte, Int] { def apply(x: Byte): Int = x.toInt }
implicit val weakByteLong = new weak_<:<[Byte, Long] { def apply(x: Byte): Long = x.toLong }
implicit val weakByteFloat = new weak_<:<[Byte, Float] { def apply(x: Byte): Float = x.toFloat }
implicit val weakByteDouble = new weak_<:<[Byte, Double] { def apply(x: Byte): Double = x.toDouble }
implicit val weakShortInt = new weak_<:<[Short, Int] { def apply(x: Short): Int = x.toInt }
implicit val weakShortLong = new weak_<:<[Short, Long] { def apply(x: Short): Long = x.toLong }
implicit val weakShortFloat = new weak_<:<[Short, Float] { def apply(x: Short): Float = x.toFloat }
implicit val weakShortDouble = new weak_<:<[Short, Double] { def apply(x: Short): Double = x.toDouble }
implicit val weakCharInt = new weak_<:<[Char, Int] { def apply(x: Char): Int = x.toInt }
implicit val weakCharLong = new weak_<:<[Char, Long] { def apply(x: Char): Long = x.toLong }
implicit val weakCharFloat = new weak_<:<[Char, Float] { def apply(x: Char): Float = x.toFloat }
implicit val weakCharDouble = new weak_<:<[Char, Double] { def apply(x: Char): Double = x.toDouble }
implicit val weakIntLong = new weak_<:<[Int, Long] { def apply(x: Int): Long = x.toLong }
implicit val weakIntFloat = new weak_<:<[Int, Float] { def apply(x: Int): Float = x.toFloat }
implicit val weakIntDouble = new weak_<:<[Int, Double] { def apply(x: Int): Double = x.toDouble }
implicit val weakLongFloat = new weak_<:<[Long, Float] { def apply(x: Long): Float = x.toFloat }
implicit val weakLongDouble = new weak_<:<[Long, Double] { def apply(x: Long): Double = x.toDouble }
implicit val weakFloatDouble = new weak_<:<[Float, Double] { def apply(x: Float): Double = x.toDouble }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment