I've found one interesting syntax stuff. It's called Infix type
.
Example:
class M[T, U]
new (Int M String)
And now I'm looking for examples of this type from some popular frameworks or libraries. Where can I find them? Any suggestions?
has bunch of them
Set ~> Option
Much like
Set[A] => Option[A] forAny {type A}
Int :: String :: Double :: HNil
is like a super-flexible version of
(Int, (String, (Double, ())))
Int :+: String :+: Double :+: CNil
is like super-flexible version of
Either[Int, Either[String, Either[Double, Nothing]]]
Int @@ NonNegative
Is zero-cost runtime analog of Int
with some information remembered in tag type
as Archeg mentioned has even more of them
String \/ Long
Is cooler version of scala's Either[String,Long]
, read more here
Boolean \&/ Long
Is handy implementation of
Either[(Boolean, Long), Either[Boolean, Long]]
String ==>> Double
is haskellest version of
collection.immutable.TreeMap[String, Double]
String :+: Float
is alternated list of things, where similar things are aggregated (added, concatenated, choosed max, etc.) instead of sequencing
From scala language, generalized type constraints
=:= => A=:=String => A must be String
<:< => A<:<String => A must be subtype of String
In scala library there is a class named ::
. It is used so you could match the list like this:
def m(l : List[Int]) = l match {
case a :: b => println("Matched") // The same as case ::(a, b) => ...
case _ => println("Not matched")
}
There are lots of other examples in libraries like scalaz I think, but this one is the most canonical.
Updated
Just understood that it is not exactly what you wanted - you wanted types. Was adding =:=
and <:<
to the answer, but @johny was faster. Please see his answer
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With