Skip to content
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

source and browse utilities broken out of the box by no PPrinter #1254

Closed
ches opened this issue Feb 17, 2022 · 0 comments · Fixed by #1284
Closed

source and browse utilities broken out of the box by no PPrinter #1254

ches opened this issue Feb 17, 2022 · 0 comments · Fixed by #1284

Comments

@ches
Copy link

ches commented Feb 17, 2022

Problem

Out of the box, the source and browse utilities are broken:

$ amm --no-home-predef
Loading...
Welcome to the Ammonite Repl 2.5.2 (Scala 2.13.8 Java 11.0.12)
@ source(new java.util.ArrayList())
cmd0.sc:1: could not find implicit value for parameter pprinter: pprint.PPrinter
val res0 = source(new java.util.ArrayList())
                 ^
Compilation Failed

@ val what = "ever"
what: String = "ever"

@ browse(what)
cmd1.sc:1: could not find implicit value for parameter pp: pprint.PPrinter
val res1 = browse(what)
                 ^
Compilation Failed

Presumably (?) Ammonite provided an implicit pretty printer instance in scope by default in the past which satisfied these, but it no longer does so.

For browse this is essentially a duplicate of #906, I propose that this issue supersedes it with the expanded scope of source and emphasis that these utilities should not be broken out of the box on examples given in the docs—it's a UX problem more than a documentation one.

Workaround

For browse we can give a PPrinter or define one in implicit scope:

@ browse(what)(repl.pprinter())
res3: os.CommandResult = CommandResult(exitCode = 0, chunks = ArraySeq())

source needs an additional CodeColors implicit. Aside from defining one from scratch I didn't find a convenient workaround, I ran into what looks like a broken macro—reference to browseSourceCommand that appears it should be browseSource now:

@ implicit val replPPrinter: pprint.PPrinter = repl.pprinter()

@ import repl.codeColorsImplicit
import repl.codeColorsImplicit

@ source(show(res1))
cmd10.sc:1: value browseSourceCommand is not a member of object ammonite.compiler.tools.SourceRuntime
val res10 = source(show(res1))
                  ^
Compilation Failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant