4 ms·
I find complex Scala declarations much harder to parse. Have a look at these examples: def scanLeft[B, That](z: B)(op: (B, A) ⇒ B)(implicit bf: CanBuildFrom[It
by terhechte 13y ago
I find complex Scala declarations much harder to parse. Have a look at these examples:
def
scanLeft[B, That](z: B)(op: (B, A) ⇒ B)(implicit bf: CanBuildFrom[Iterable[A], B, That]): That
implicit def
flatten5[A, B, C, D, E, F](f: (A, B, C, D, E) ⇒ F): ((ImplicitConversions.this)#~[(ImplicitConversions.this)#~[(ImplicitConversions.this)#~[(ImplicitConversions.this)#~[A, B], C], D], E]) ⇒ F
implicit def
flatten5[A, B, C, D, E, F](f: (A, B, C, D, E) ⇒ F): (~[~[~[~[A, B], C], D], E]) ⇒ F
These are, thankfully, exceptions and most declarations are easier to read, nevertheless, as a Scala beginner, it takes me quite some time parsing such a declaration when I intend to utilize the function in question. But that's probably the price to pay for complex static typing.
- bjz_ 13y agoWhat does the tildes do in `(~[~[~[~[A, B], C], D], E])`?
- terhechte 13y agoIt's a wrapper over a sequence of matches: http://www.scala-lang.org/api/current/#scala.util.parsing.combinator.Parsers$$tilde http://www.scala-lang.org/api/current/#scala.util.parsing.co... Given p1: Parser[A] and p2: Parser[B], a parser composed with p1 ~ p2 will have type Parser[~[A, B]]. The successful result of the parser can be extracted from this case class. In this case it will use the [[[[A,B] C] D] E] sequence to compose A,B,C,D,E together in order to produce F (A-F are types). At least if I understand things correctly, I've never used flatten5.