Scala - ~> [Tilde arrow] explanation

less than 1 minute read

"~>" is a place holder for type.
Main reason to use "~>" is to make readable on type A goes to type B. This is possible because Scala allow to express in in-fix notation for pre-fix expression.

1
2
3
trait Order[~>[_,_]] {
   def sort[A,B](f: A ~> B): B
}

is equivalent to

1
2
3
trait Order[M[_,_]] {
   def sort[A,B](f: M[A, B]): B
}

https://stackoverflow.com/questions/10085951/scala-tilde-greater-than-operator