From 462f807726f64cfa41ce7081042bfe77fe6e1dfe Mon Sep 17 00:00:00 2001 From: Tim Spence Date: Thu, 19 May 2022 15:30:41 +0100 Subject: [PATCH 1/3] Add a FAQ section to the docs --- docs/faq.md | 23 +++++++++++++++++++++++ site-docs/sidebars.json | 1 + 2 files changed, 24 insertions(+) create mode 100644 docs/faq.md diff --git a/docs/faq.md b/docs/faq.md new file mode 100644 index 0000000000..1f6dfb2267 --- /dev/null +++ b/docs/faq.md @@ -0,0 +1,23 @@ +--- +id: faq +title: FAQ +--- + +## Scala CLI + +[Scala CLI](https://scala-cli.virtuslab.org/) can run both `.sc` files and `.scala` files. `.sc` files allow definitions at the top level and a main method is synthesized to run it. Unfortunately this does not work well with `IO#unsafeRunSync`. You should put your cats-effect code inside the `run` method of an `IOApp` and save it as a `.scala` file instead. + +```scala-cli +//> using scala "2.13.8" +//> using lib "org.typelevel::cats-effect:3.3.11" + +import cats.effect._ + +object HelloWorld extends IOApp.Simple { + override val run: IO[Unit] = IO.println("Hello world") +} +``` + +```sh +scala-cli Hello.scala +``` diff --git a/site-docs/sidebars.json b/site-docs/sidebars.json index e125909fef..ed02528d09 100644 --- a/site-docs/sidebars.json +++ b/site-docs/sidebars.json @@ -4,6 +4,7 @@ "getting-started", "concepts", "tutorial", + "faq", "migration-guide" ], "Core Runtime": [ From bfcea0caf6b3cb8ab9de016c806e11474c1890f1 Mon Sep 17 00:00:00 2001 From: Tim Spence Date: Thu, 19 May 2022 15:37:53 +0100 Subject: [PATCH 2/3] Make scala-cli snippet ScalaJS friendly --- docs/faq.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/faq.md b/docs/faq.md index 1f6dfb2267..27611f36e3 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -9,7 +9,7 @@ title: FAQ ```scala-cli //> using scala "2.13.8" -//> using lib "org.typelevel::cats-effect:3.3.11" +//> using lib "org.typelevel::cats-effect::3.3.11" import cats.effect._ From 9aadc96fcf05e3afaecc0a9d50bd986c1e289475 Mon Sep 17 00:00:00 2001 From: Tim Spence Date: Thu, 19 May 2022 15:52:33 +0100 Subject: [PATCH 3/3] Review suggestion --- docs/faq.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/faq.md b/docs/faq.md index 27611f36e3..6106ae8324 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -14,7 +14,7 @@ title: FAQ import cats.effect._ object HelloWorld extends IOApp.Simple { - override val run: IO[Unit] = IO.println("Hello world") + val run: IO[Unit] = IO.println("Hello world") } ```