Skip to content

Instantly share code, notes, and snippets.

View TonioGela's full-sized avatar
🐈

Antonio Gelameris TonioGela

🐈
View GitHub Profile

During the last year the Scala tooling scene got a new addition, namely scala-cli and the scala-cli toolkit, and I think that neither of those needs a presentation.

At Typelevel we immediately fall in love with this idea of delivering all (of most of) our stack power with a single import in single file scripts, specifically given how tightly integrated and interconnected the libraries we develop already are.

For this very reason, we promptly created and publish the Typelevel's toolkit, a meta library that packs a good number of Typelevel's libraries and that makes possible for scala-cli users to create applications that can solve a vast number of problems.

Needless to say that everything relies on Cats Effect Effect System, an effect system that it's known to be not easy to use for newcomers.

Doing a side to side comparison with the scala-cli toolkit we've realised that, despite offering the same functionalities, our toolkit was lacking (specifically for newcomers) some "ease of use" and that this is most

@TonioGela
TonioGela / Excel.scala
Created February 16, 2024 16:47
Autoderivation of typeclasses in Scala 3
//> using scala 3.4.0
//> using dep com.norbitltd::spoiwo::2.2.1
//> using dep org.typelevel::cats-core::2.10.0
import spoiwo.model.*
import spoiwo.natures.xlsx.Model2XlsxConversions.XlsxSheet
import cats.kernel.Monoid
import cats.syntax.all.*
import scala.compiletime.*
import scala.deriving.Mirror
@TonioGela
TonioGela / stty.scala
Created November 13, 2023 08:40
Fancy JLine inspired way of handling single stdin keypresses on tty based terminals
//> using dep co.fs2::fs2-io::3.9.3
import fs2.*
import fs2.io.process.*
import cats.effect.*
import cats.syntax.all.*
import sun.misc.*
import cats.effect.std.Dispatcher
object Foo extends IOApp.Simple:
@TonioGela
TonioGela / json.scala
Last active April 14, 2023 16:27
Circe example with and without auto derivation of codecs
//> using scala "3.2.1"
//> using lib "io.circe::circe-jawn::latest.release"
//> using lib "org.scalacheck::scalacheck::latest.release"
import io.circe.*
import io.circe.jawn.*
import io.circe.syntax.*
import org.scalacheck.Gen
val jsonString = """{"foo": "bar"}"""
//> using scala "3.2.1"
//> using lib "com.monovore::decline-effect::2.4.1"
//> using lib "co.fs2::fs2-io::3.4.0"
//> using packaging.output "mkString"
//> using platform "scala-native"
//> using nativeMode "release-fast"
//> using nativeGc "none"
import cats.effect.*
import cats.effect.std.*
//> using scala "2.13.10"
//> using lib "io.spray::spray-json::1.3.6"
import spray.json._
// il tuo wrapper di cose nullabili
sealed trait PatchValue[+T]
object PatchValue {
object ToDelete extends PatchValue[Nothing]
case class Value[T](t: T) extends PatchValue[T]
@TonioGela
TonioGela / EmberServer.scala
Last active December 17, 2022 10:20
Native EmberServer compiled with Scala Native
//> using scala "3.2.1"
//> using platform "native"
//> using nativeMode "release-full"
//> using nativeLinking "-L/usr/local/opt/openssl@3/lib"
//> using packaging.output "server"
//> using lib "com.armanbilge::epollcat::0.1.1"
//> using lib "org.http4s::http4s-ember-server::0.23.16"
//> using lib "org.http4s::http4s-dsl::0.23.16"
//> using lib "org.http4s::http4s-circe::0.23.16"
//> using lib "io.circe::circe-generic::0.14.3"