aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/java/coffee/liz/lambda/eval/Value.java
blob: dc459ff57356fa7448dd887f8b795c98f0c316df (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package coffee.liz.lambda.eval;

import coffee.liz.lambda.ast.Expression;

/**
 * Represents a runtime value produced by evaluation.
 */
public sealed interface Value permits Value.Closure, Value.Application, Value.Free {

    /**
     * A closure capturing an environment, parameter, and body.
     *
     * @param env
     *            the captured environment
     * @param parameter
     *            the bound parameter name
     * @param body
     *            the lambda body expression
     */
    record Closure(Environment env, String parameter, Expression body) implements Value {
    }

    /**
     * A symbolic application of a function to an argument.
     *
     * @param function
     *            the function
     * @param argument
     *            the argument
     */
    record Application(Value function, Value argument) implements Value {
    }

    /**
     * A free variable.
     *
     * @param name
     *            the variable name
     */
    record Free(String name) implements Value {
    }
}