hmemcpy / milewski-ctfp-pdf

Bartosz Milewski's 'Category Theory for Programmers' unofficial PDF and LaTeX source
https://bartoszmilewski.com/2014/10/28/category-theory-for-programmers-the-preface/
Other
10.88k stars 578 forks source link

Tupeling return type in prodToSum method in section 6.4 #210

Closed ASRagab closed 4 years ago

ASRagab commented 4 years ago

Explicitly Tupling return in prodToSum method in Chapter 6

Mostly because it will produce these warnings if "-Xlint:adapted-args" is turned on, and it makes more clear that sumToProd is the inverse function as it does tuple the pair in the pattern match

[REDACTED]/src/main/scala/Main.scala:5:30: adapted the argument list to the expected 2-tuple: add additional parens instead
[warn]         signature: Left.apply[A, B](value: A): scala.util.Left[A,B]
[warn]   given arguments: x, y
[warn]  after adaptation: Left((x, y): (A, B))
[warn]         case Left(y)  => Left(x, y)
[warn]                              ^
[warn] [REDACTED]/src/main/scala/Main.scala:6:31: adapted the argument list to the expected 2-tuple: add additional parens instead
[warn]         signature: Right.apply[A, B](value: B): scala.util.Right[A,B]
[warn]   given arguments: x, z
[warn]  after adaptation: Right((x, z): (A, C))
[warn]         case Right(z) => Right(x, z)
[warn]                               ^
[warn] two warnings found
[info] Done compiling.

Should I wait for this to get merged in before updating the errata file?

hmemcpy commented 4 years ago

Good catch! Considering adapted args was deprecated, it's a good change! Thank you!

hmemcpy commented 4 years ago

And yes, please add this to the scala-errata, appreciate it! (Perhaps in another PR?)

ASRagab commented 4 years ago

And yes, please add this to the scala-errata, appreciate it! (Perhaps in another PR?)

Will do. Just grabbing the commit hash.

hmemcpy commented 4 years ago

You can link to this PR directly. I'm usually adding the commit hashes if some changes were made in master directly without a PR.

ASRagab commented 4 years ago

You can link to this PR directly. I'm usually adding the commit hashes if some changes were made in master directly without a PR.

Ah, makes sense, I'll do that.