typelevel / toolkit

Quickstart your next app with the Typelevel Toolkit!
https://typelevel.org/toolkit
Apache License 2.0
92 stars 9 forks source link

Document how to use from Typelevel toolkit from REPL #121

Open armanbilge opened 8 months ago

armanbilge commented 8 months ago
zetashift commented 8 months ago

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
TonioGela commented 8 months ago

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

zetashift commented 8 months ago

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?

armanbilge commented 8 months ago

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:.

TonioGela commented 7 months ago

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.

zetashift commented 7 months ago

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.