Documentation
¶
Overview ¶
Package value is the FEEL/DMN runtime value model: the Value interface and its concrete kinds (null, boolean, number, string, the temporal types, list, context, range and function), together with equality, ordering and arithmetic that follow FEEL semantics — most importantly decimal numbers (never float64, ADR-0007) and pervasive null propagation.
It is a foundational package imported by the FEEL compiler, the boxed expression and decision-table engines and the public API. It lives apart from package feel so that value names such as Number and Kind do not collide with the lexer's token kinds.
Index ¶
- func Compare(a, b Value) (int, bool)
- func IsNull(v Value) bool
- type Bool
- type Context
- type Date
- type DateTime
- type DaysTimeDuration
- type Function
- type Kind
- type List
- type Number
- func (n Number) Abs() Number
- func (n Number) Ceiling() Number
- func (n Number) CeilingTo(scale int32) (Number, bool)
- func (n Number) Cmp(o Number) int
- func (n Number) Decimal() *apd.Decimal
- func (n Number) Even() (bool, bool)
- func (n Number) Exp() (Number, bool)
- func (n Number) Floor() Number
- func (n Number) FloorTo(scale int32) (Number, bool)
- func (n Number) Int64() (int64, bool)
- func (n Number) IsInteger() bool
- func (n Number) IsZero() bool
- func (Number) Kind() Kind
- func (n Number) Ln() (Number, bool)
- func (n Number) Modulo(o Number) (Number, bool)
- func (n Number) Odd() (bool, bool)
- func (n Number) RoundDown(scale int32) (Number, bool)
- func (n Number) RoundHalfDown(scale int32) (Number, bool)
- func (n Number) RoundHalfEven(scale int32) (Number, bool)
- func (n Number) RoundHalfUp(scale int32) (Number, bool)
- func (n Number) RoundUp(scale int32) (Number, bool)
- func (n Number) SecondsNanos() (sec int64, nanos int, ok bool)
- func (n Number) Sqrt() (Number, bool)
- func (n Number) String() string
- type Range
- type Str
- type Time
- type Value
- func Add(a, b Value) Value
- func BoolOf(b bool) Value
- func Div(a, b Value) Value
- func Equal(a, b Value) Value
- func Exp(a, b Value) Value
- func Member(v Value, name string) (Value, bool)
- func Mul(a, b Value) Value
- func Neg(a Value) Value
- func ParseDuration(s string) (Value, error)
- func Sub(a, b Value) Value
- type YearsMonthsDuration
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context is an ordered key→value map. Iteration follows insertion order; two contexts are equal when they hold the same entries regardless of order.
type Date ¶
type Date struct {
// contains filtered or unexported fields
}
Date is a calendar date with no time-of-day or zone. It is stored as midnight UTC for the given day.
func DateFromComponents ¶
DateFromComponents builds a Date from year, month and day.
type DateTime ¶
type DateTime struct {
// contains filtered or unexported fields
}
DateTime is a date and time, optionally with a zone.
func CombineDateTime ¶
CombineDateTime merges a date with a time-of-day into a date-and-time, taking the zone from the time component.
func NewDateTime ¶
NewDateTime returns a zoned DateTime for the instant t. The location of t determines the rendered zone suffix (UTC renders as "Z"). It is the entry point used when converting a Go time.Time input into a FEEL value.
func ParseDateTime ¶
ParseDateTime parses "YYYY-MM-DDTHH:MM:SS(.fff)?" with an optional zone suffix.
type DaysTimeDuration ¶
type DaysTimeDuration struct {
// contains filtered or unexported fields
}
DaysTimeDuration is a duration measured in seconds/nanoseconds (may be negative). It cannot be converted to a YearsMonthsDuration.
func NewDaysTimeDuration ¶
func NewDaysTimeDuration(d time.Duration) DaysTimeDuration
NewDaysTimeDuration builds a days-and-time duration from a time.Duration.
func (DaysTimeDuration) Duration ¶
func (d DaysTimeDuration) Duration() time.Duration
Duration returns the duration as a time.Duration.
func (DaysTimeDuration) Kind ¶
func (DaysTimeDuration) Kind() Kind
Kind returns KindDaysTimeDuration.
func (DaysTimeDuration) String ¶
func (d DaysTimeDuration) String() string
type Function ¶
Function is a callable FEEL value (builtin or user-defined). The Call closure is wired up by the compiler (WP-06); the value model only carries it.
type Kind ¶
type Kind uint8
Kind identifies a FEEL value's type. The FEEL type system distinguishes two duration types that are not interconvertible (months vs. seconds).
type Number ¶
type Number struct {
// contains filtered or unexported fields
}
Number is a FEEL number backed by an arbitrary-precision decimal.
func MustNumber ¶
MustNumber parses s and panics on error; for tests and constants.
func ParseNumber ¶
ParseNumber parses a FEEL numeric literal (decimal, optional exponent; no hex/octal). It returns an error for malformed or non-finite input.
func (Number) CeilingTo ¶
CeilingTo rounds n up (toward +infinity) to scale digits after the decimal point, matching FEEL ceiling(n, scale).
func (Number) Cmp ¶
Cmp compares two numbers as -1, 0 or +1. Integer operands (the common case in decision-table range and equality tests) compare natively as int64, skipping the decimal alignment apd.Cmp performs; the result is identical.
func (Number) FloorTo ¶
FloorTo rounds n down (toward -infinity) to scale digits after the decimal point, matching FEEL floor(n, scale).
func (Number) Int64 ¶
Int64 returns n truncated to an int64 and whether it fit exactly as an integer.
func (Number) Modulo ¶
Modulo returns the FEEL modulo of n by o, defined as n - o*floor(n/o) so the result takes the sign of the divisor. A zero divisor yields ok=false.
func (Number) RoundDown ¶
RoundDown rounds n to scale digits toward zero (FEEL "round down", truncation).
func (Number) RoundHalfDown ¶
RoundHalfDown rounds n to scale digits, ties toward zero (FEEL "round half down").
func (Number) RoundHalfEven ¶
RoundHalfEven rounds n to scale digits after the decimal point using round-half-even, matching the FEEL decimal(n, scale) built-in.
func (Number) RoundHalfUp ¶
RoundHalfUp rounds n to scale digits, ties away from zero (FEEL "round half up").
func (Number) RoundUp ¶
RoundUp rounds n to scale digits, away from zero on ties and otherwise toward the next magnitude (FEEL "round up").
func (Number) SecondsNanos ¶
SecondsNanos splits a non-negative second count into whole seconds and the remaining nanoseconds, for the time()/date and time() constructors, which accept a fractional second (e.g. time(12,59,1.3,…) → …01.3…). The fraction is rounded half-even to nanosecond precision. ok is false when n is negative or its whole-second part does not fit an int64.
type Time ¶
type Time struct {
// contains filtered or unexported fields
}
Time is a time-of-day, optionally with a zone. The date part of the backing instant is a fixed reference day and is not significant.
func NewTime ¶
func NewTime(hour, minute, second, nanos int, offset *DaysTimeDuration) Time
NewTime builds a time-of-day from components. When offset is non-nil the time is zoned at that fixed UTC offset; otherwise it is a local time without a zone.
type Value ¶
type Value interface {
Kind() Kind
// String renders the value in its canonical FEEL form.
String() string
// contains filtered or unexported methods
}
Value is a FEEL runtime value. Implementations are immutable; operations return new values. The null value is represented by Null, never a Go nil, so callers can always call methods safely.
var Null Value = nullValue{}
Null is the single FEEL null value. Most operations propagate it.
func Equal ¶
Equal implements FEEL `=` semantics. It returns a Bool: two nulls are equal, a null and a non-null are not, and values of different kinds are not equal. Equality never yields null.
func Member ¶
Member returns the named FEEL property of a temporal or duration value and reports whether v has such a property. It backs path access for these types; non-temporal values return ok=false so the caller can fall back to context member lookup.
func ParseDuration ¶
ParseDuration parses an ISO 8601 duration into either a years-months or a days-time duration. The two FEEL duration types are disjoint, so a literal mixing year/month and day/time components is rejected. Fractional components (e.g. PT1.5H) are not yet accepted — a documented limitation tracked for a later refinement.
type YearsMonthsDuration ¶
type YearsMonthsDuration struct {
// contains filtered or unexported fields
}
YearsMonthsDuration is a duration measured in whole months (may be negative).
func NewYearsMonthsDuration ¶
func NewYearsMonthsDuration(months int64) YearsMonthsDuration
NewYearsMonthsDuration builds a years-and-months duration from a month count.
func YearsMonthsBetween ¶
func YearsMonthsBetween(from, to Date) YearsMonthsDuration
YearsMonthsBetween returns the difference from→to as a whole-month duration, truncated toward zero (e.g. 2020-01-01 → 2021-06-15 is P1Y5M).
func (YearsMonthsDuration) Kind ¶
func (YearsMonthsDuration) Kind() Kind
Kind returns KindYearsMonthsDuration.
func (YearsMonthsDuration) Months ¶
func (d YearsMonthsDuration) Months() int64
Months returns the total number of months (may be negative).
func (YearsMonthsDuration) String ¶
func (d YearsMonthsDuration) String() string