toolkit icon indicating copy to clipboard operation
toolkit copied to clipboard

Document how to use from Typelevel toolkit from REPL

Open armanbilge opened this issue 2 years ago • 6 comments

  • https://github.com/scala/toolkit/discussions/37

armanbilge avatar Nov 09 '23 19:11 armanbilge

What is the incantation for this?

❯ scala-cli repl --with-toolkit=typelevel:toolkit
Downloading 3 dependencies and 2 internal dependencies
[error]  Error downloading org.typelevel:toolkit_3:toolkit
[error]   not found: /home/rishi/.ivy2/local/org.typelevel/toolkit_3/toolkit/ivys/ivy.xml
[error]   not found: https://repo1.maven.org/maven2/org/typelevel/toolkit_3/toolkit/toolkit_3-toolkit.pom
[error]   not found: /home/rishi/.cache/scalacli/local-repo/1.0.5/org.typelevel/toolkit_3/toolkit/ivys/ivy.xml
[error]   No fallback URL found
[error] COMMAND_LINE
[error]  Error downloading org.typelevel:toolkit-test_3:toolkit
[error]   not found: /home/rishi/.ivy2/local/org.typelevel/toolkit-test_3/toolkit/ivys/ivy.xml
[error]   not found: https://repo1.maven.org/maven2/org/typelevel/toolkit-test_3/toolkit/toolkit-test_3-toolkit.pom
[error]   not found: /home/rishi/.cache/scalacli/local-repo/1.0.5/org.typelevel/toolkit-test_3/toolkit/ivys/ivy.xml
[error]   No fallback URL found

EDIT: got it!

 scala-cli repl --toolkit=typelevel:latest

zetashift avatar Nov 09 '23 19:11 zetashift

WOW! we definitively need that kitchen sink import now :D

TonioGela avatar Nov 10 '23 12:11 TonioGela

WOW! we definitively need that kitchen sink import now :D

This was exactly my first thought as well!! How cool of a reply experience would that be.

Tho I believe we still need to do unsafeRunSync everywhere no?

zetashift avatar Nov 10 '23 12:11 zetashift

Tho I believe we still need to do unsafeRunSync everywhere no?

Yeah, this is annoying 😒 it's just how it is tho. I guess the REPL-sink import should bring in the implicit runtime that it Just Works:tm:.

armanbilge avatar Nov 10 '23 16:11 armanbilge

Tho I believe we still need to do unsafeRunSync everywhere no?

Yeah, this is annoying 😒 it's just how it is tho. I guess the REPL-sink import should bring in the implicit runtime that it Just Works™️.

We can probably namespace the imports then: we can have an import org.typelevel.toolkit.* that is the scripts' kitchen sink import and a import org.typelevel.toolkit.repl.* that extends it with the required implicit (import cats.effect.unsafe.implicits.*).

And now we just need finishing the discussion in #2 :D

[EDIT] There won't be anything preventing the users from importing the repl package in scripts though 🤔 Also, the tooling might get confused.

TonioGela avatar Nov 13 '23 17:11 TonioGela

It might still be worth it imho, e.g. imagine being able to use it in Markdown: https://scala-cli.virtuslab.org/docs/guides/markdown/

and then you could have some runbook that deploys stuff in the markdown file with docs etc all using IO! Or any other literate programming thingy. Maybe hook-up a frontend and to it and serve a notebook-type of environment even... IMHO, it makes a lot of sense to atleast experiment with it.

zetashift avatar Nov 13 '23 21:11 zetashift