@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
50 lines (43 loc) • 1.04 kB
JavaScript
import { Scope } from "../scopes/index.js"
import { OptionType$ } from "../typecheck/index.js"
import { Expr } from "./Expr.js"
/**
* @import { Site } from "@helios-lang/compiler-utils"
* @import { TypeCheckContext } from "../index.js"
* @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 {TypeCheckContext} ctx
* @param {Scope} scope
* @returns {Type}
*/
evalInternal(ctx, scope) {
const someType = this._someTypeExpr.evalAsType(ctx, scope)
return OptionType$(someType)
}
/**
* @returns {string}
*/
toString() {
return `Option[${this._someTypeExpr.toString()}]`
}
}