UNPKG

@helios-lang/compiler

Version:

Helios is a Domain Specific Language that compiles to Plutus-Core (i.e. Cardano on-chain validator scripts). Helios is a non-Haskell alternative to Plutus. With this library you can compile Helios scripts and build Cardano transactions, all you need to bu

48 lines (41 loc) 946 B
import { Scope } from "../scopes/index.js" import { OptionType$ } from "../typecheck/index.js" import { Expr } from "./Expr.js" /** * @typedef {import("@helios-lang/compiler-utils").Site} Site * @typedef {import("../typecheck/index.js").Type} Type */ /** * Option[SomeType] expression * @internal */ export class OptionTypeExpr extends Expr { /** * @private * @readonly * @type {Expr} */ _someTypeExpr /** * @param {Site} site * @param {Expr} someTypeExpr */ constructor(site, someTypeExpr) { super(site) this._someTypeExpr = someTypeExpr } /** * @param {Scope} scope * @returns {Type} */ evalInternal(scope) { const someType = this._someTypeExpr.evalAsType(scope) return OptionType$(someType) } /** * @returns {string} */ toString() { return `Option[${this._someTypeExpr.toString()}]` } }