Skip to content

Instantly share code, notes, and snippets.

@erdeszt
erdeszt / Direct.scala
Last active May 10, 2024 06:59
Direct style scala effect tracking
package direct
import java.util.UUID
import scala.language.experimental.saferExceptions
import Contains.given
import izumi.reflect.macrortti.LightTypeTag
import izumi.reflect.{*, given}
import sttp.tapir.*
@erdeszt
erdeszt / 1_Solver.scala
Last active December 6, 2024 16:05
Advent of code "framework"
import scala.util.Using
trait Solver[Day <: Int: ValueOf, Part <: Int: ValueOf]:
/** Solves the `Part` of the solution for the `Day`
*
* @param input
* The lines of the input file
* @return
* The solution
@erdeszt
erdeszt / 0RaiseV2.kt
Last active September 25, 2025 22:11
Kotlin checked exceptions
package org.gl.common
sealed interface Result<out Error, out Value> {
fun <Value1> map(f: (Value) -> Value1): Result<Error, Value1> = when (this) {
is Failure -> Failure(error)
is Success -> Success(f(value))
}
fun <Error1> leftMap(f: (Error) -> Error1): Result<Error1, Value> = when (this) {
is Failure -> Failure(f(error))