Skip to content

Instantly share code, notes, and snippets.

@JamesWang
JamesWang / scala3_csv_type_class_derivation_example.scala
Last active June 4, 2025 15:02
Scala 3 Type Class Derivation example
import scala.deriving.Mirror.ProductOf
object Decoder {
type Row = List[String]
extension (row: Row)
def as[T](using p: ProductOf[T], d: RowDecoder[p.MirroredElemTypes]): T =
p.fromProduct(d.decode(row))
trait RowDecoder[A]:
package aten.ssl;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import javax.net.ssl.SSLServerSocketFactory;
public static String formatWithStackInfo(String message) {
/**
* ex.getStackTrace()[0] is this formatWithStackInfo() method ex.getStackTrace()[1]
* is your method where you call this method
*/
StackTraceElement ste = new Throwable().getStackTrace()[1];
String callerClassName = ste.getClassName();
int callerLineNumber = ste.getLineNumber();