SkillAgentSearch skills...

Mat

Lightweight Scala 3 library for materializing types into values at compile time.

Install / Use

/learn @scytrowski/Mat
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

mat

Scala MvnRepository License: MIT

⚠️ Artifact moved from io.github.scytrowski.mat to me.cytrowski.mat

mat is a lightweight Scala 3 library for materializing types into values at compile time.

It provides a typeclass-based approach for turning types like tuples, literal types, or case classes into values using inline and Mirror.


✨ Features

  • Materialize literal types like 5, "hello", true
  • Recursively materialize tuples: (1, "abc", true)
  • Recursively materialize named tuples: (a = 1, b = "abc", c = true)
  • Materialize case classes via Mirror.ProductOf
  • Materialize singleton sealed trait based ADTs via Mirror.SumOf
  • Safe fallback with materializeOpt[A] returning Option

📦 Examples

Materialize a literal value

import me.cytrowski.mat.*

val x: 42 = materialize[42]
// x: 42

Materialize a tuple

import me.cytrowski.mat.*

val x: (true, 'd', "abc") = materialize[(true, 'd', "abc")]
// x: (true, 'd', "abc")

Materialize a named tuple

import me.cytrowski.mat.*

val x: (a: true, b: 'd', c: "abc") = materialize[(a: true, b: 'd', c: "abc")]
// x: (a = true, b = 'd', c = "abc")

Materialize a case object

import me.cytrowski.mat.*

case object SomeObject

val x: SomeObject.type = materialize[SomeObject.type]
// x: SomeObject

Materialize a case class

import me.cytrowski.mat.*

case class SomeClass[A](a: A)

val x: SomeClass[15] = materialize[SomeClass[15]]
// x: SomeClass(15)

Materialize a singleton ADT variant

import me.cytrowski.mat.*

sealed trait SomeADT

case object SingletonVariant extends SomeADT

val x: SingletonVariant.type = materialize[SomeADT]
// x: SingletonVariant

Provide custom materialization logic

import me.cytrowski.mat.*

sealed abstract class SomeClass

object SomeClass:
  val instance: SomeClass = new SomeClass {}

given CustomMaterialize[SomeClass]:
override type Out = SomeClass
override def apply(): SomeClass = SomeClass.instance

val x: SomeClass = materialize[SomeClass]
// x: SomeClass.instance

Require a materializable type

import me.cytrowski.mat.*

def doSomethingWithMaterializableType[A: Materialize] = ???

🚧 TODO

  • [ ] Support intersection types - e.g.: 5 & Int should materialize as 5
  • [ ] Support union types - e.g.: 5 | String should materialize as 5
  • [ ] Support nested singleton ADTs

📄 License

This project is licensed under the MIT License.

You are free to use, copy, modify, and distribute it with attribution.

View on GitHub
GitHub Stars7
CategoryDevelopment
Updated23d ago
Forks0

Languages

Scala

Security Score

90/100

Audited on Mar 8, 2026

No findings