shapeless-guide icon indicating copy to clipboard operation
shapeless-guide copied to clipboard

Compiler flags for literal types?

Open davegurnell opened this issue 8 years ago • 7 comments

Reported by @d6y:

Box on "Literal types in Scala", p. 56

There's a flag to enable this stuff, right? Worth saying that?

As of Lightbend Scala....., with the -wibble flag enabled, we now have direct syntax support...

davegurnell avatar Nov 01 '16 18:11 davegurnell

The example

val theAnswer: 42 = 42

does not work in (non-Typelevel) Scala 2.11.11 nor 2.12.3.

scala> val theAnswer: 42 = 42
<console>:1: error: identifier expected but integer literal found.
       val theAnswer: 42 = 42
                      ^

According to the callout on p56 it should, right?

metasim avatar Sep 07 '17 17:09 metasim

Do you have scalacOptions += "-Yliteral-types" in your build.sbt? I think you need to enable that for literal types. I can't remember how much I go into this stuff in the book, but I wouldn't be surprised if it wasn't clear enough.

On Thu, Sep 7, 2017 at 6:37 PM Simeon H.K. Fitch [email protected] wrote:

The example

val theAnswer: 42 = 42

does not work Lightbend 2.11.11 nor 2.12.3.

scala> val theAnswer: 42 = 42 :1: error: identifier expected but integer literal found. val theAnswer: 42 = 42 ^

According to the callout on p56 it should, right?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/underscoreio/shapeless-guide/issues/12#issuecomment-327870926, or mute the thread https://github.com/notifications/unsubscribe-auth/AAOI52gEdAfBF9RfYw28V1ZwDmaACMTtks5sgCnAgaJpZM4Kma36 .

davegurnell avatar Sep 08 '17 10:09 davegurnell

When I posted that I was looking at the PDF version at work. At home I have the paperback version, and noted there that it does reference the -Yliteral-types flag. So it looks like the Lulu version is more up to date than the free PDF version.

All that said, this is what I'm getting with 2.12.3:

sfitch$ scalac -version
Scala compiler version 2.12.3 -- Copyright 2002-2017, LAMP/EPFL and Lightbend, Inc.
sfitch$ scalac -Yliteral-types
scalac error: bad option: '-Yliteral-types'
  scalac -help  gives more information

metasim avatar Sep 08 '17 13:09 metasim

Thanks for the update. I'll look into the book text in a next set of updates.

I'm guessing 2.12.3 may have -Yliteral-types enabled by default?

On Fri, Sep 8, 2017 at 2:02 PM Simeon H.K. Fitch [email protected] wrote:

When I posted that I was looking at the PDF version at work. At home I have the paperback version, and noted there that it does reference the -Yliteral-types flag. So it looks like the Lulu version is more up to date than the free PDF version.

All that said, this is what I'm getting with 2.12.3:

sfitch$ scalac -version Scala compiler version 2.12.3 -- Copyright 2002-2017, LAMP/EPFL and Lightbend, Inc. sfitch$ scalac -Yliteral-types scalac error: bad option: '-Yliteral-types' scalac -help gives more information

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/underscoreio/shapeless-guide/issues/12#issuecomment-328097104, or mute the thread https://github.com/notifications/unsubscribe-auth/AAOI50YRa8WKwtQvhwAmSgKfakFPAi3jks5sgTrPgaJpZM4Kma36 .

davegurnell avatar Sep 08 '17 15:09 davegurnell

Nope:

sfitch$ scala -version
Scala code runner version 2.12.3 -- Copyright 2002-2017, LAMP/EPFL and Lightbend, Inc.

sfitch$ scala -Yliteral-types
bad option: '-Yliteral-types'

Usage: scala <options> [<script|class|object|jar> <arguments>]
   or  scala -help

All options to scalac (see scalac -help) are also allowed.

sfitch$ scala
Welcome to Scala 2.12.3 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_121).
Type in expressions for evaluation. Or try :help.

scala> val theAnswer: 42 = 42
<console>:1: error: identifier expected but integer literal found.
       val theAnswer: 42 = 42
                      ^

metasim avatar Sep 08 '17 18:09 metasim

Update on this: it looks like the PR for literal types isn't yet merged into Lightbend Scala. Probably worth updating the text to say "...and coming soon in Lightbend Scala".

d6y avatar Sep 15 '17 15:09 d6y

Thanks for this. I'll correct for the next version. To be honest I get confused as to what's available where. Too many updates! Still, it's a good problem to have :) On Fri, 15 Sep 2017 at 16:51, Richard Dallaway [email protected] wrote:

Update on this: it looks like the PR for literal types isn't yet merged into Lightbend Scala. Probably worth updating the text to say "...and coming soon in Lightbend Scala".

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/underscoreio/shapeless-guide/issues/12#issuecomment-329822342, or mute the thread https://github.com/notifications/unsubscribe-auth/AAOI5ztlEwpYQVePnQsfw5YHNKvzlA8Kks5sipzdgaJpZM4Kma36 .

davegurnell avatar Sep 17 '17 15:09 davegurnell