I know in Scala one can declare type alias with syntax like type MyString = String
. But recently I learned a new way to declare type that I was not aware of, and it’s interesting.
The example is on the blog - https://blog.chmist.com/composing-monadic-functions-with-kleisli-4ef2f9a2d6c5
Where it declares a type
type ToErrorOr[A, B] = Kleisli[ErrorOr, A, B]
and in the statement of val stringToInt ...
it declares with returned type String ToErrorOr Int
instead of ToErrorOr[String, Int]
. Why can the program declare with such expression? Any reasons behind that? And any similar usages?
Thanks