compiler-plugin / arrow.meta.quotes.nameddeclaration.notstubbed / FunctionLiteral


class FunctionLiteral : FunctionNotStubbed<KtFunctionLiteral>


A template destructuring Scope for a KtFunctionLiteral.

import arrow.meta.Meta
import arrow.meta.CliPlugin
import arrow.meta.invoke
import arrow.meta.quotes.Transform
import arrow.meta.quotes.functionLiteral

val Meta.reformatFunctionLiteral: CliPlugin
   get() =
     "Reformat Function Literal" {
         functionLiteral({ true }) { functionNotStubbed ->
             replacing = functionNotStubbed,
             newDeclaration = """{$`(params)`$blockExpression}""".functionLiteral

A function literal is a special notation to simplify how a function is defined. There are two types of function literals in Kotlin:

Lambda expression

A lambda expression is a short way to define a function. It tends to be more explicit than anonymous functions:

val increment: (Int) -> Unit = { x -> x + 1 }

Anonymous function

An anonymous function is just another way to define a function:

val increment: (Int) -> Unit = fun(x) { x + 1 }


<init> ”””{$(params)$blockExpression}””“.functionLiteralFunctionLiteral(value: KtFunctionLiteral, name: Name? = value.nameAsName, blockExpression: BlockExpression = BlockExpression(value.bodyBlockExpression))


blockExpression val blockExpression: BlockExpression
name val name: Name?
value val value: KtFunctionLiteral


identity fun ElementScope.identity(): FunctionLiteral

Extension Functions

map fun <K : KtElement> Scope<K>.map(f: (K) -> K): Scope<K>
orEmpty fun <K : KtElement> Scope<K>?.orEmpty(): Scope<K>

Do you like Arrow?

Arrow Org