-
Notifications
You must be signed in to change notification settings - Fork 1.1k
REPL: uppercase strings have different colors than lowercase #1681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think the correct thing to do here is to print the string with scala> "\""
res0: String = " // Currently
res0: String = "\"" // Proposed behavior I think that's a trade-off worth making |
Thanks for reporting @rethab . @felixmulder can you have a look at this one? |
I believe my time is best spent elsewhere at the moment. The issue stems from how we render results. The main culprit is resultExtractor, which needs to be changed. This method needs to correctly render strings. But there are a number of issues/questions that will arise when somebody starts to look at this:
I think the issue needs to clarify these three points before somebody starts working on this. After that I think that it is an excellent entry-level task that could be handled by outside contributors. |
Regarding 1. and 2., you indeed want to print values as valid Scala, and
Maybe there's some local REPL-only solution, but the wider issue remains. Indeed, many languages with REPLs (say Haskell or Lisps) distinguish how the REPL shows values as expressions (say Haskell If you want an existing solution to this (and other problems), there's among others @lihaoyi's PPrint which was born for his Ammonite REPL (and I imagine there are other ports inspired by Haskell's |
Just an FYI, since this is a compiler that needs to bootstrap we can't and don't want to have external dependencies on scala 2 artefacts. There are a couple that are a necessary for the time being (scala-library-2.11.5 and friends) but they will be removed eventually. We have previously talked about revamping case classes. Perhaps a show/print typeclass could be added in the same go... (On mobile now so hard to link, could you comment there?) I would love it if we could add a typeclass like you suggest. |
Right—toString was discussed in #1341, and that ends up leading to issue #1347 on generic programming. In fact a Maybe there's space for some specific fix to the original issue, but it might not be worth it. |
One approach would be to try and replace pprint's typeclass derivation with Shapeless, which I heard (?) is pretty robust. Another is to dump the derivation altogether and go with runtime reflection, which is great (tho doesn't work on Scala.js) But yes, the output of the REPL should be properly quoted and valid Scala, as far as is possible. Collections, case classes, strings, whatever. You are not going to be able to fix the |
What I wrote is misleading so let me clarify. Felix had good questions on printer design, and to answer those one might want to start from your library design, regardless of how much code can be reused. Among other things, dotty doesn't support current macros (though it'll support scala.meta) or current shapeless. For the derivation mechanism let's look at #1347. |
Oh ok. I think all the non-derivation parts of the library are great:
All that stuff is nice :) and there to use. If we could hook it up to some non-gnarly derivation mechanism we'd be all set |
Closed via #1761 |
The text was updated successfully, but these errors were encountered: