Skip to content

Instantly share code, notes, and snippets.

@splittingfield
Created December 5, 2011 21:34
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 splittingfield/1435472 to your computer and use it in GitHub Desktop.
Save splittingfield/1435472 to your computer and use it in GitHub Desktop.
Workaround for specialization issue for known datatypes
import com.azavea.math.Numeric
import com.azavea.math.EasyImplicits._
trait F1[@specialized T, @specialized W] extends Function1[T,W] {
def apply(a:T):W
}
abstract class F12D[@specialized T:Numeric:Manifest] extends F1[T,Double]{
def apply(a:T):Double
}
abstract class F12I[@specialized T:Numeric:Manifest] extends F1[T,Int] {
def apply(a:T):Int
}
class Bar[@specialized T:Numeric:Manifest] {
def barToDouble[@specialized S:Numeric:Manifest,W <: F1[T,S]](f:W)=f(numeric[T].zero)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment