Kotlin glue code that keeps me sane
Find a file
2025-11-14 18:37:34 +01:00
core refactored option/result and docs 2025-11-14 18:37:34 +01:00
gradle/wrapper init 2025-11-12 10:10:51 +01:00
pipelines init 2025-11-12 10:10:51 +01:00
.gitignore init 2025-11-12 10:10:51 +01:00
build.gradle.kts init 2025-11-12 10:10:51 +01:00
gradle.properties init 2025-11-12 10:10:51 +01:00
gradlew init 2025-11-12 10:10:51 +01:00
gradlew.bat init 2025-11-12 10:10:51 +01:00
README.md init 2025-11-12 10:10:51 +01:00
settings.gradle.kts init 2025-11-12 10:10:51 +01:00

Magik

This library adds many things I like from other languages to kotlin (such as monads and lenses) and also some general-purpose utility classes that I often find myself wanting.

There are also some more specific things, but those are in separate modules to keep the core lean and mean

Todo

Pipelines

Fix them

Pattern matching as a lib

class Match<T, R>(private val x: T) {
  private var res: R? = null
  infix fun case(pred: (T)->Boolean to (T)->R) {
    if (res == null && pred.first(x)) res = pred.second(x)
  }
  fun otherwise(f: (T)->R): R = res ?: f(x)
}

fun <T,R> match(x: T, block: Match<T,R>.()->Unit): R =
  Match<T,R>(x).apply(block).otherwise { error("No match") }

// usage
val label = match(42) {
  case({ it % 2 == 0 } to { "even" })
  case({ it > 100 } to { "big" })
}

Math Stuff

  • Vectors
  • Matrixes
  • Tensors