/** * This module defines the mutually recursive types for Values and Observations as defined in the Marlowe Specification. * @see Section 2.1.5 of the {@link https://github.com/input-output-hk/marlowe/releases/download/v3/specification-v3.pdf | Marlowe Specification} * @packageDocumentation */ import * as t from "io-ts/lib/index.js"; import { ChoiceId } from "./choices.js"; import { AccountId } from "./payee.js"; import { Token } from "./token.js"; /** * Represents the amount of money available in a participants internal account * @category Value */ export interface AvailableMoney { amount_of_token: Token; in_account: AccountId; } /** * {@link !io-ts-usage | Dynamic type guard} for the {@link @marlowe.io/language-core-v1!index.AvailableMoney | available money type}. * @category Value */ export declare const AvailableMoneyGuard: t.Type; /** * Search [[lower-name-builders]] * @hidden */ export declare const constant: (constant: bigint) => bigint; /** * A constant value * @category Value */ export type Constant = bigint; /** * {@link !io-ts-usage | Dynamic type guard} for the {@link @marlowe.io/language-core-v1!index.Constant | constant value type}. * @category Value */ export declare const ConstantGuard: t.Type; /** * Represents the start time as a POSIXTime of the {@link @marlowe.io/language-core-v1!semantics.Transaction} this value is * evaluated in. * @category Value */ export type TimeIntervalStart = "time_interval_start"; /** * {@link !io-ts-usage | Dynamic type guard} for the {@link @marlowe.io/language-core-v1!index.TimeIntervalStart | time interval start type}. * @category Value */ export declare const TimeIntervalStartGuard: t.Type; /** * Represents the end time as a POSIXTime of the {@link @marlowe.io/language-core-v1!semantics.Transaction} this value is * evaluated in. * @category Value */ export type TimeIntervalEnd = "time_interval_end"; /** * {@link !io-ts-usage | Dynamic type guard} for the {@link @marlowe.io/language-core-v1!index.TimeIntervalEnd | time interval end type}. * @category Value */ export declare const TimeIntervalEndGuard: t.LiteralC<"time_interval_end">; /** * Represents `- negate` * @category Value */ export interface NegValue { negate: Value; } /** * {@link !io-ts-usage | Dynamic type guard} for the {@link @marlowe.io/language-core-v1!index.NegValue | neg value type}. * @category Value */ export declare const NegValueGuard: t.Type; /** * Represents `add + and` * @category Value */ export interface AddValue { add: Value; and: Value; } /** * {@link !io-ts-usage | Dynamic type guard} for the {@link @marlowe.io/language-core-v1!index.AddValue | add value type}. * @category Value */ export declare const AddValueGuard: t.Type; /** * Represents `value - minus` * @category Value */ export interface SubValue { value: Value; minus: Value; } /** * {@link !io-ts-usage | Dynamic type guard} for the {@link @marlowe.io/language-core-v1!index.SubValue | sub value type}. * @category Value */ export declare const SubValueGuard: t.Type; /** * Search [[lower-name-builders]] * @hidden */ export declare const mulValue: (multiply: Value, times: Value) => { multiply: Value; times: Value; }; /** * Represents `multiply * times` * @category Value */ export interface MulValue { multiply: Value; times: Value; } /** * {@link !io-ts-usage | Dynamic type guard} for the {@link @marlowe.io/language-core-v1!index.MulValue | mul value type}. * @category Value */ export declare const MulValueGuard: t.Type; /** * Represents `divide / by` * @category Value */ export interface DivValue { divide: Value; by: Value; } /** * {@link !io-ts-usage | Dynamic type guard} for the {@link @marlowe.io/language-core-v1!index.DivValue | div value type}. * @category Value */ export declare const DivValueGuard: t.Type; /** * Represents the {@link @marlowe.io/language-core-v1!index.ChosenNum} for a {@link @marlowe.io/language-core-v1!index.ChoiceId}. * @category Value */ export type ChoiceValue = { value_of_choice: ChoiceId; }; /** * {@link !io-ts-usage | Dynamic type guard} for the {@link ChoiceValue | choice value type}. * @category Value */ export declare const ChoiceValueGuard: t.Type; /** * Is an identifier for a {@link @marlowe.io/language-core-v1!index.Let} binding * @category Value */ export type ValueId = string; /** * {@link !io-ts-usage | Dynamic type guard} for the {@link ValueId | value id type}. * @category Value */ export declare const ValueIdGuard: t.Type; /** * Represents the bound value of a {@link @marlowe.io/language-core-v1!index.Let} expression. * @category Value */ export interface UseValue { use_value: ValueId; } /** * {@link !io-ts-usage | Dynamic type guard} for the {@link UseValue | use value type}. * @category Value */ export declare const UseValueGuard: t.Type; /** * Ternary conditional expression * @category Value */ export interface Cond { if: Observation; then: Value; else: Value; } /** * {@link !io-ts-usage | Dynamic type guard} for the {@link Cond | cond type}. * @category Value */ export declare const CondGuard: t.Type; /** * Marlowe allows the representation of numeric `Values` using the following constructs * @category Value */ export type Value = AvailableMoney | Constant | NegValue | AddValue | SubValue | MulValue | DivValue | ChoiceValue | TimeIntervalStart | TimeIntervalEnd | UseValue | Cond; /** * {@link !io-ts-usage | Dynamic type guard} for the {@link Value | value type}. * @category Value */ export declare const ValueGuard: t.Type; /** * Pattern match object on the Value type * @category Value * @hidden */ export type ValueMatcher = { availableMoney: (value: AvailableMoney) => T; constant: (value: Constant) => T; negValue: (value: NegValue) => T; addValue: (value: AddValue) => T; subValue: (value: SubValue) => T; mulValue: (value: MulValue) => T; divValue: (value: DivValue) => T; choiceValue: (value: ChoiceValue) => T; timeIntervalStart: (value: TimeIntervalStart) => T; timeIntervalEnd: (value: TimeIntervalEnd) => T; useValue: (value: UseValue) => T; cond: (value: Cond) => T; }; /** * Pattern matching on the Value type * @hidden * @category Value */ export declare function matchValue(matcher: ValueMatcher): (value: Value) => T; export declare function matchValue(matcher: Partial>): (value: Value) => T | undefined; /** * Observes `both && and` * @category Observation */ export interface AndObs { both: Observation; and: Observation; } /** * {@link !io-ts-usage | Dynamic type guard} for the {@link AndObs | and type}. * @category Observation */ export declare const AndObsGuard: t.Type; /** * Observes `either || or` * @category Observation */ export interface OrObs { either: Observation; or: Observation; } /** * {@link !io-ts-usage | Dynamic type guard} for the {@link OrObs | or type}. * @category Observation */ export declare const OrObsGuard: t.Type; /** * Negates the `not` observation * @category Observation */ export interface NotObs { not: Observation; } /** * {@link !io-ts-usage | Dynamic type guard} for the {@link NotObs | not type}. * @category Observation */ export declare const NotObsGuard: t.Type; /** * Observes if the `chose_something_for` choice was made * @category Observation */ export interface ChoseSomething { chose_something_for: ChoiceId; } /** * {@link !io-ts-usage | Dynamic type guard} for the {@link ChoseSomething | choose something type}. * @category Observation */ export declare const ChoseSomethingGuard: t.Type; /** * Observes if `value == equal_to` * @category Observation */ export interface ValueEQ { value: Value; equal_to: Value; } /** * {@link !io-ts-usage | Dynamic type guard} for the {@link ValueEQ | value eq type}. * @category Observation */ export declare const ValueEQGuard: t.Type; /** * Observes if `value > gt` * @category Observation */ export interface ValueGT { value: Value; gt: Value; } /** * {@link !io-ts-usage | Dynamic type guard} for the {@link ValueGT | value greater than type}. * @category Observation */ export declare const ValueGTGuard: t.Type; /** * Observes if `value >= ge_than` * @category Observation */ export interface ValueGE { value: Value; ge_than: Value; } /** * {@link !io-ts-usage | Dynamic type guard} for the {@link ValueGE | value greater or equal type}. * @category Observation */ export declare const ValueGEGuard: t.Type; /** * Observes if `value < lt` * @category Observation */ export interface ValueLT { value: Value; lt: Value; } /** * {@link !io-ts-usage | Dynamic type guard} for the {@link ValueLT | value lower than type}. * @category Observation */ export declare const ValueLTGuard: t.Type; /** * Observes if `value <= le_than` * @category Observation */ export interface ValueLE { value: Value; le_than: Value; } /** * {@link !io-ts-usage | Dynamic type guard} for the {@link ValueLE | value lower or equal type}. * @category Observation */ export declare const ValueLEGuard: t.Type; /** * Marlowe allows the representation of boolean `Observation`s using the following constructs * @category Observation */ export type Observation = AndObs | OrObs | NotObs | ChoseSomething | ValueEQ | ValueGT | ValueGE | ValueLT | ValueLE | boolean; /** * {@link !io-ts-usage | Dynamic type guard} for the {@link @marlowe.io/language-core-v1!index.Observation | observation type}. * @category Observation */ export declare const ObservationGuard: t.Type; /** * Pattern match object on the Observation type * @category Observation * @hidden */ export type ObservationMatcher = { andObs: (observation: AndObs) => T; orObs: (observation: OrObs) => T; notObs: (observation: NotObs) => T; choseSomething: (observation: ChoseSomething) => T; valueEQ: (observation: ValueEQ) => T; valueGT: (observation: ValueGT) => T; valueGE: (observation: ValueGE) => T; valueLT: (observation: ValueLT) => T; valueLE: (observation: ValueLE) => T; trueObs: (observation: true) => T; falseObs: (observation: false) => T; }; /** * Pattern matching on the Observation type * @hidden * @category Observation */ export declare function matchObservation(matcher: ObservationMatcher): (observation: Observation) => T; export declare function matchObservation(matcher: Partial>): (observation: Observation) => T | undefined; //# sourceMappingURL=value-and-observation.d.ts.map