I hope this account is about to become a lot more active soon. Finalizing my plan to leap from big social media to scalable/personal social community. I've got a lot to share. Stay tuned...

#dump_it #dump_fb #ownyourcontent #portablecommunity #formless #shapeless #gettingready

@jz

The combination of #Scala version 3 and #Typelevel #Cats and #Kittens is pretty neat. "Kittens" is a library that has derived type classes for Cats. I just learned about Kittens yesterday. "Kittens" uses #Shapeless libraries underneath.

Sample Source Code:

https://scastie.scala-lang.org/bgI5mqPYRR2NQA3QYrVFBQ

Scastie - An interactive playground for Scala.

//> using scala 3.8.1 //> using option -language:experimental.saferExceptions //> using option -language:experimental.captureChecking // Describes computations that can fail with error `E` final class CanThrow[-E] // Internal exception used to jump to the catch block private final case class Break[E](value: E, label: CanThrow[E]) extends RuntimeException(null, null, false, false) // Library version of `throw` def failWith[A](a: A)(using l: CanThrow[A]): Nothing = throw Break(a, l) // Provides a way to catch errors. object Catch: def apply[A, E](op: CanThrow[E] ?=> A)(default: E => A): A = given label: CanThrow[E] = new CanThrow() try op catch case Break(value, `label`) => default(value) // Error types sealed trait Error extends Exception case class NegativeNumber(i: Int) extends Error case class InvalidInput(s: String) extends Error // sqrt can fail if its argument is negative. def sqrt(i: Int)(using CanThrow[NegativeNumber]): Double = if i >= 0 then math.sqrt(i) else failWith(NegativeNumber(i)) // parse can fail if its argument is not a valid int. def parse(s: String)(using CanThrow[InvalidInput]): Int = scala.util.Try(s.toInt).getOrElse(failWith(InvalidInput(s))) // Composing both widens the type of the error to the parent of `NegativeNumber` and `InvalidInput`. def composed(s: String)(using CanThrow[Error]): Double = sqrt(parse(s)) // I like this better - auto-widening is nice, but note how `Error` is not sealed: `composedSubtype` // forces me to deal with error cases that don't exist. def composedBetter(s: String)(using CanThrow[NegativeNumber | InvalidInput] ): Double = sqrt(parse(s)) def printSqrt(s: String): Unit = Catch(println(composedBetter(s))): case NegativeNumber(i) => println(s"Negative number: $i") case InvalidInput(s) => println(s"Invalid input: '$s'") @main def run = printSqrt("abc") printSqrt("-4") printSqrt("4")

Ooop right forgot hashtags for discoverability. (I swear I'll get used to social media some day)

Looking for a specific style of #clothing #recommendations - help me find shops that can let me show my inner #witchy #cryptid self shine through. If folks are interested I can also share the places I've already found and had good experiences with! See the first post for #aesthetic goals.

I'd also accept #cyberpunk #hippie vibes, and styles that range from a little #slutty to #shapeless #void

"Bits of Shapeless part 2: Generic Derivation" - https://enear.github.io/2016/09/27/bits-of-shapeless-2/ #scala #shapeless