Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use context bound in type alias

Tags:

scala

Is it possible to use context bounds in type aliases in Scala?

e.g

type U = A : B
like image 786
Timo Westkämper Avatar asked Mar 13 '12 08:03

Timo Westkämper


1 Answers

No, because the context bound is actually a shorthand for an extra implicit parameter.

For instance:

def sort[A : Ordering](xs: Seq[A])

is a shorthand form for

def sort[A](xs: Seq[A])(implicit ordering: Ordering[A])

and this cannot be represented in a type definition.

like image 117
Jean-Philippe Pellet Avatar answered Oct 18 '22 18:10

Jean-Philippe Pellet