Skip to content

Instantly share code, notes, and snippets.

@majk-p
majk-p / main.scala
Created October 21, 2025 10:50
Scala 3.3.7 false positive import warning for `typeCheckErrors`
//> using options -Wunused:imports
import scala.compiletime.testing.{Error, typeCheckErrors}
object DummySpec extends App {
case class A(x: Int)
val errors: List[Error] = typeCheckErrors("""
import com.example.MyTypeClass
summon[MyTypeClass[A]]
@majk-p
majk-p / main.scala
Created October 16, 2025 17:03
Cats Effect 3.7.0-RC1 vs SN 0.5.9
//> using platform native
//> using nativeVersion 0.5.9
//> using dep org.typelevel::cats-effect::3.7.0-RC1
import cats.effect.ExitCode
import cats.effect.IO
import cats.effect.IOApp
object App extends IOApp {
@majk-p
majk-p / main.scala
Created April 4, 2025 13:48
[fix] Found A => A instead of missing given instance - fixed by chaning order of givens
//> using scala 3.3.5
trait StreamArnFor[A] {
val name: String
}
object api {
def expect[
CompanionObject,
@majk-p
majk-p / main.scala
Created April 4, 2025 13:47
Found A => A instead of missing given instance
//> using scala 3.3.5
trait StreamArnFor[A] {
val name: String
}
object api {
def expect[
CompanionObject,
@majk-p
majk-p / lib.scala
Created January 9, 2025 14:28
Weird behavior of -Ywarn-unused:privates
package example
private object lib {
def doStuff = println("Hello from MyLib")
}
@majk-p
majk-p / sort.scala
Last active December 18, 2024 15:00
Selection sort
import scala.annotation.tailrec
object SelectionSort {
@tailrec
def sort(arr: List[Int], acc: List[Int] = Nil): List[Int] = {
if (arr.isEmpty) acc.reverse
else {
val min = arr.min
val (left, right) = arr.span(_ != min)
@majk-p
majk-p / main.py
Created December 12, 2024 20:45
atproto to smithy converter
import os
import json
import argparse
from typing import Dict, Any, List
def convert_atproto_type_to_smithy(atproto_type: str, nested: bool = False) -> str:
"""
Convert ATP types to Smithy types with more robust type mapping
"""
type_mapping = {
@majk-p
majk-p / Encoder.scala
Last active November 20, 2024 13:40
Bug in union-derivation 0.2.0
import cats.Show
import cats.syntax.all.*
trait Encoder[A] {
def encode(v: A): String
}
object Encoder extends EncoderDerivation {
object instances {
@majk-p
majk-p / main.scala
Created October 8, 2024 05:25
Scala 3.3.3 -> 3.3.4 regression example
//> using dep "org.typelevel::cats-effect:3.5.4"
//> using scala "3.3.3"
import cats.Functor
import cats.effect.std.UUIDGen
import cats.syntax.all.*
import java.util.UUID
final class MyId private (val id: String)
@majk-p
majk-p / oslib-weaver-expecty.test.scala
Created September 13, 2024 09:27
Reproduction example of multisegment os.Path breaking expecty
//> using dep "com.disneystreaming::weaver-cats:0.8.4"
//> using dep "com.lihaoyi::os-lib:0.10.7"
import weaver.*
import os.Path
object ExampleSuite extends FunSuite {
test("os-lib test") {
val path: os.Path = ???