Skip to content

matejcerny/function-name

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

function-name

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.2"

About

Simple Scala 3 macro which generates name of the function.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages