6

In another question I ended up with a value of type A => => B. What does this mean?

I've always been led to understand that => A is not actually a type, but a way an argument can be declared to work with call-by-name semantics. But if it's not a type, what does A => => B mean?

Community
  • 1
  • 1
Martijn
  • 11,964
  • 12
  • 50
  • 96
  • 3
    Please take a look at #5 in the answer to this: http://stackoverflow.com/questions/32802104/some-questions-about-difference-between-call-by-name-and-0-arity-functions . In short `=> A` is a type, but scala compiler does not recognize it. Interpreter often use this notation in it's responses about the type, so you can consider it as a part of type signature – Archeg Oct 06 '15 at 11:33
  • 1
    `A => => B` is a syntax error. Maybe you mean `=> A => B`? – kiritsuku Oct 06 '15 at 16:35
  • @sschaef no. The compiler told me `found : R => U, required: R => => U` – Martijn Oct 06 '15 at 16:37
  • 3
    It seems to be a bug in the compiler. `A => => B` should actually be displayed as `A => (=> B)` in the error message, because a call by name parameter is expected in the return type. However, they are called call by name parameter not by accident, they are not valid as a return type, therefore the compiler should reduce it to `A => B`, which it obviously fails to do. – kiritsuku Oct 06 '15 at 16:51
  • 1
    @sschaef I think it's worth promoting your comment to an answer. – metasim Jun 03 '16 at 00:43

0 Answers0