Skip to content

Latest commit

 

History

History
38 lines (27 loc) · 1.37 KB

File metadata and controls

38 lines (27 loc) · 1.37 KB

function-name

Scala Native Scala.js Latest version Build Status codecov

Simple Scala 3 macro which generates name of the function as an opaque type.

Usage

import io.github.matejcerny.functionname.*

def someFunction(): Unit =
  val fnName = functionName
  println(fnName.value) // someFunction

One use case could be logging:

def log(message: String)(using fnName: FunctionName): Unit =
  println(s"${fnName.value}: $message")

def someFunction(): Unit =
  log("Hello!")(using functionName)

Installation

Add the library as a dependency:

libraryDependencies += "io.github.matejcerny" %% "function-name" % "0.2.3"