Registry / utility / magnolia-2-12

magnolia-2-12

JSON →
library0.17.0javamavenunverified

A generic macro-based library for automatic derivation of typeclass instances in Scala.

<dependency> <groupId>com.propensive</groupId> <artifactId>magnolia_2.12</artifactId> <version>0.17.0</version> </dependency>
INSTALL
IMPORT
SIG · MAGNOLIA-2-12
M
magnolia-2-12
utilityjavav0.17.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Magnolia
magnolia.Magnolia

Derive a Show typeclass for a case class

import magnolia._ import scala.language.experimental.macros // Define a typeclass and derive instances automatically sealed trait Show[T] { def show(t: T): String } object Show extends Derivation[Show] { def join[T](ctx: CaseClass[Show, T]): Show[T] = (t: T) => ctx.parameters.map { p => s"${p.label}=${p.typeclass.show(p.dereference(t))}" }.mkString("{", ",", "}") override def split[T](ctx: SealedTrait[Show, T]): Show[T] = (t: T) => ctx.dispatch(t) { sub => sub.typeclass.show(sub.cast(t)) } } case class Person(name: String, age: Int) val personShow = implicitly[Show[Person]] println(personShow.show(Person("John", 30)))
Debug
Known issues

No known issues recorded.

Upgrade
Version history
0.17.0latest on Maven
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
magnolia-2-12 — mvn dependency:get magnolia-2-12 · libregistry