import * as _ from "@preserves/core"; export const $1 = 1; export const $Boolean = Symbol.for("Boolean"); export const $ByteString = Symbol.for("ByteString"); export const $Double = Symbol.for("Double"); export const $Float = Symbol.for("Float"); export const $SignedInteger = Symbol.for("SignedInteger"); export const $String = Symbol.for("String"); export const $Symbol = Symbol.for("Symbol"); export const $and = Symbol.for("and"); export const $any = Symbol.for("any"); export const $atom = Symbol.for("atom"); export const $definitions = Symbol.for("definitions"); export const $dict = Symbol.for("dict"); export const $dictof = Symbol.for("dictof"); export const $lit = Symbol.for("lit"); export const $named = Symbol.for("named"); export const $or = Symbol.for("or"); export const $pointer = Symbol.for("pointer"); export const $rec = Symbol.for("rec"); export const $ref = Symbol.for("ref"); export const $schema = Symbol.for("schema"); export const $setof = Symbol.for("setof"); export const $tuple = Symbol.for("tuple"); export const $tuple$STAR$ = Symbol.for("tuple*"); export const $version = Symbol.for("version"); export const __lit5 = false; export type _ptr = never; export type _val = _.Value<_ptr>; export type Schema = {"version": Version, "pointer": PointerName, "definitions": Definitions}; export type Version = null; export type PointerName = ({"_variant": "Ref", "value": Ref} | {"_variant": "false"}); export type Definitions = _.KeyedDictionary; export type Definition = ( {"_variant": "or", "patterns": Array} | {"_variant": "Alternative", "value": Alternative} ); export type NamedAlternative = {"variantLabel": string, "alternative": Alternative}; export type Alternative = ( {"_variant": "and", "patterns": Array} | {"_variant": "Pattern", "value": Pattern} ); export type Pattern = ( {"_variant": "SimplePattern", "value": SimplePattern} | {"_variant": "CompoundPattern", "value": CompoundPattern} ); export type SimplePattern = ( {"_variant": "any"} | {"_variant": "atom", "atomKind": AtomKind} | {"_variant": "pointer"} | {"_variant": "lit", "value": _val} | {"_variant": "Ref", "value": Ref} ); export type CompoundPattern = ( {"_variant": "rec", "label": NamedPattern, "fields": NamedPattern} | {"_variant": "tuple", "patterns": Array} | { "_variant": "tuple*", "fixed": Array, "variable": NamedSimplePattern } | {"_variant": "setof", "pattern": SimplePattern} | {"_variant": "dictof", "key": SimplePattern, "value": SimplePattern} | {"_variant": "dict", "entries": DictionaryEntries} ); export type DictionaryEntries = _.KeyedDictionary<_val, NamedSimplePattern, _ptr>; export type AtomKind = ( {"_variant": "Boolean"} | {"_variant": "Float"} | {"_variant": "Double"} | {"_variant": "SignedInteger"} | {"_variant": "String"} | {"_variant": "ByteString"} | {"_variant": "Symbol"} ); export type NamedSimplePattern = ( {"_variant": "named", "value": NamedSimplePattern_} | {"_variant": "anonymous", "value": SimplePattern} ); export type NamedPattern = ( {"_variant": "named", "value": NamedSimplePattern_} | {"_variant": "anonymous", "value": Pattern} ); export type NamedSimplePattern_ = {"name": symbol, "pattern": SimplePattern}; export type Ref = {"module": ModulePath, "name": symbol}; export type ModulePath = Array; export const _toPtr = () => { throw new _.DecodeError("Pointers forbidden"); }; export function Schema(version: Version, pointer: PointerName, definitions: Definitions): Schema {return {version, pointer, definitions};} export function Version(): Version {return null;} export namespace PointerName { export function Ref(value: Ref): PointerName {return {"_variant": "Ref", value};}; export function $false(): PointerName {return {"_variant": "false"};}; } export function Definitions(value: _.KeyedDictionary): Definitions {return value;} export namespace Definition { export function or(patterns: Array): Definition {return {"_variant": "or", patterns};}; export function Alternative(value: Alternative): Definition {return {"_variant": "Alternative", value};}; } export function NamedAlternative(variantLabel: string, alternative: Alternative): NamedAlternative {return {variantLabel, alternative};} export namespace Alternative { export function and(patterns: Array): Alternative {return {"_variant": "and", patterns};}; export function Pattern(value: Pattern): Alternative {return {"_variant": "Pattern", value};}; } export namespace Pattern { export function SimplePattern(value: SimplePattern): Pattern {return {"_variant": "SimplePattern", value};}; export function CompoundPattern(value: CompoundPattern): Pattern {return {"_variant": "CompoundPattern", value};}; } export namespace SimplePattern { export function any(): SimplePattern {return {"_variant": "any"};}; export function atom(atomKind: AtomKind): SimplePattern {return {"_variant": "atom", atomKind};}; export function pointer(): SimplePattern {return {"_variant": "pointer"};}; export function lit(value: _val): SimplePattern {return {"_variant": "lit", value};}; export function Ref(value: Ref): SimplePattern {return {"_variant": "Ref", value};}; } export namespace CompoundPattern { export function rec(label: NamedPattern, fields: NamedPattern): CompoundPattern {return {"_variant": "rec", label, fields};}; export function tuple(patterns: Array): CompoundPattern {return {"_variant": "tuple", patterns};}; export function tuple$STAR$(fixed: Array, variable: NamedSimplePattern): CompoundPattern {return {"_variant": "tuple*", fixed, variable};}; export function setof(pattern: SimplePattern): CompoundPattern {return {"_variant": "setof", pattern};}; export function dictof(key: SimplePattern, value: SimplePattern): CompoundPattern {return {"_variant": "dictof", key, value};}; export function dict(entries: DictionaryEntries): CompoundPattern {return {"_variant": "dict", entries};}; } export function DictionaryEntries(value: _.KeyedDictionary<_val, NamedSimplePattern, _ptr>): DictionaryEntries {return value;} export namespace AtomKind { export function Boolean(): AtomKind {return {"_variant": "Boolean"};}; export function Float(): AtomKind {return {"_variant": "Float"};}; export function Double(): AtomKind {return {"_variant": "Double"};}; export function SignedInteger(): AtomKind {return {"_variant": "SignedInteger"};}; export function String(): AtomKind {return {"_variant": "String"};}; export function ByteString(): AtomKind {return {"_variant": "ByteString"};}; export function Symbol(): AtomKind {return {"_variant": "Symbol"};}; } export namespace NamedSimplePattern { export function named(value: NamedSimplePattern_): NamedSimplePattern {return {"_variant": "named", value};}; export function anonymous(value: SimplePattern): NamedSimplePattern {return {"_variant": "anonymous", value};}; } export namespace NamedPattern { export function named(value: NamedSimplePattern_): NamedPattern {return {"_variant": "named", value};}; export function anonymous(value: Pattern): NamedPattern {return {"_variant": "anonymous", value};}; } export function NamedSimplePattern_(name: symbol, pattern: SimplePattern): NamedSimplePattern_ {return {name, pattern};} export function Ref(module: ModulePath, name: symbol): Ref {return {module, name};} export function ModulePath(value: Array): ModulePath {return value;} export function asSchema(v: _val): Schema { let result = toSchema(v); if (result === void 0) throw new TypeError(`Invalid Schema: ${_.stringify(v)}`); return result; } export function toSchema(v: _val): undefined | Schema { let result: undefined | Schema; if (_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v)) { let _tmp0: (null) | undefined; _tmp0 = _.is(v.label, $schema) ? null : void 0; if (_tmp0 !== void 0) { if (_.Dictionary.isDictionary<_ptr>(v[0])) { let _tmp1: (_val) | undefined; if ((_tmp1 = v[0].get($version)) !== void 0) { let _tmp2: (Version) | undefined; _tmp2 = toVersion(_tmp1); if (_tmp2 !== void 0) { let _tmp3: (_val) | undefined; if ((_tmp3 = v[0].get($pointer)) !== void 0) { let _tmp4: (PointerName) | undefined; _tmp4 = toPointerName(_tmp3); if (_tmp4 !== void 0) { let _tmp5: (_val) | undefined; if ((_tmp5 = v[0].get($definitions)) !== void 0) { let _tmp6: (Definitions) | undefined; _tmp6 = toDefinitions(_tmp5); if (_tmp6 !== void 0) {result = {"version": _tmp2, "pointer": _tmp4, "definitions": _tmp6};}; }; }; }; }; }; }; }; }; return result; } export function asVersion(v: _val): Version { let result = toVersion(v); if (result === void 0) throw new TypeError(`Invalid Version: ${_.stringify(v)}`); return result; } export function toVersion(v: _val): undefined | Version { let _tmp0: (null) | undefined; let result: undefined | Version; _tmp0 = _.is(v, $1) ? null : void 0; if (_tmp0 !== void 0) {result = _tmp0;}; return result; } export function asPointerName(v: _val): PointerName { let result = toPointerName(v); if (result === void 0) throw new TypeError(`Invalid PointerName: ${_.stringify(v)}`); return result; } export function toPointerName(v: _val): undefined | PointerName { let _tmp0: (Ref) | undefined; let result: undefined | PointerName; _tmp0 = toRef(v); if (_tmp0 !== void 0) {result = {"_variant": "Ref", "value": _tmp0};}; if (result === void 0) { let _tmp1: (null) | undefined; _tmp1 = _.is(v, __lit5) ? null : void 0; if (_tmp1 !== void 0) {result = {"_variant": "false"};}; }; return result; } export function asDefinitions(v: _val): Definitions { let result = toDefinitions(v); if (result === void 0) throw new TypeError(`Invalid Definitions: ${_.stringify(v)}`); return result; } export function toDefinitions(v: _val): undefined | Definitions { let _tmp0: (_.KeyedDictionary) | undefined; let result: undefined | Definitions; if (_.Dictionary.isDictionary<_ptr>(v)) { _tmp0 = new _.KeyedDictionary(); for (const [_tmp2, _tmp1] of v) { let _tmp3: (symbol) | undefined; _tmp3 = typeof _tmp2 === 'symbol' ? _tmp2 : void 0; if (_tmp3 !== void 0) { let _tmp4: (Definition) | undefined; _tmp4 = toDefinition(_tmp1); if (_tmp4 !== void 0) {_tmp0.set(_tmp3, _tmp4); continue;}; }; _tmp0 = void 0; break; }; if (_tmp0 !== void 0) {result = _tmp0;}; }; return result; } export function asDefinition(v: _val): Definition { let result = toDefinition(v); if (result === void 0) throw new TypeError(`Invalid Definition: ${_.stringify(v)}`); return result; } export function toDefinition(v: _val): undefined | Definition { let result: undefined | Definition; if (_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v)) { let _tmp0: (null) | undefined; _tmp0 = _.is(v.label, $or) ? null : void 0; if (_tmp0 !== void 0) { if (_.Array.isArray(v[0])) { let _tmp1: (Array<_val>) | undefined; let _tmp2: (Array) | undefined; _tmp1 = v[0]; { _tmp2 = []; for (const _tmp3 of _tmp1) { let _tmp4: (NamedAlternative) | undefined; _tmp4 = toNamedAlternative(_tmp3); if (_tmp4 !== void 0) {_tmp2.push(_tmp4); continue;}; _tmp2 = void 0; break; }; if (_tmp2 !== void 0) {result = {"_variant": "or", "patterns": _tmp2};}; }; }; }; }; if (result === void 0) { let _tmp5: (Alternative) | undefined; _tmp5 = toAlternative(v); if (_tmp5 !== void 0) {result = {"_variant": "Alternative", "value": _tmp5};}; }; return result; } export function asNamedAlternative(v: _val): NamedAlternative { let result = toNamedAlternative(v); if (result === void 0) throw new TypeError(`Invalid NamedAlternative: ${_.stringify(v)}`); return result; } export function toNamedAlternative(v: _val): undefined | NamedAlternative { let result: undefined | NamedAlternative; if (_.Array.isArray(v) && v.length === 2) { let _tmp0: (string) | undefined; _tmp0 = typeof v[0] === 'string' ? v[0] : void 0; if (_tmp0 !== void 0) { let _tmp1: (Alternative) | undefined; _tmp1 = toAlternative(v[1]); if (_tmp1 !== void 0) {result = {"variantLabel": _tmp0, "alternative": _tmp1};}; }; }; return result; } export function asAlternative(v: _val): Alternative { let result = toAlternative(v); if (result === void 0) throw new TypeError(`Invalid Alternative: ${_.stringify(v)}`); return result; } export function toAlternative(v: _val): undefined | Alternative { let result: undefined | Alternative; if (_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v)) { let _tmp0: (null) | undefined; _tmp0 = _.is(v.label, $and) ? null : void 0; if (_tmp0 !== void 0) { if (_.Array.isArray(v[0])) { let _tmp1: (Array<_val>) | undefined; let _tmp2: (Array) | undefined; _tmp1 = v[0]; { _tmp2 = []; for (const _tmp3 of _tmp1) { let _tmp4: (NamedPattern) | undefined; _tmp4 = toNamedPattern(_tmp3); if (_tmp4 !== void 0) {_tmp2.push(_tmp4); continue;}; _tmp2 = void 0; break; }; if (_tmp2 !== void 0) {result = {"_variant": "and", "patterns": _tmp2};}; }; }; }; }; if (result === void 0) { let _tmp5: (Pattern) | undefined; _tmp5 = toPattern(v); if (_tmp5 !== void 0) {result = {"_variant": "Pattern", "value": _tmp5};}; }; return result; } export function asPattern(v: _val): Pattern { let result = toPattern(v); if (result === void 0) throw new TypeError(`Invalid Pattern: ${_.stringify(v)}`); return result; } export function toPattern(v: _val): undefined | Pattern { let _tmp0: (SimplePattern) | undefined; let result: undefined | Pattern; _tmp0 = toSimplePattern(v); if (_tmp0 !== void 0) {result = {"_variant": "SimplePattern", "value": _tmp0};}; if (result === void 0) { let _tmp1: (CompoundPattern) | undefined; _tmp1 = toCompoundPattern(v); if (_tmp1 !== void 0) {result = {"_variant": "CompoundPattern", "value": _tmp1};}; }; return result; } export function asSimplePattern(v: _val): SimplePattern { let result = toSimplePattern(v); if (result === void 0) throw new TypeError(`Invalid SimplePattern: ${_.stringify(v)}`); return result; } export function toSimplePattern(v: _val): undefined | SimplePattern { let _tmp0: (null) | undefined; let result: undefined | SimplePattern; _tmp0 = _.is(v, $any) ? null : void 0; if (_tmp0 !== void 0) {result = {"_variant": "any"};}; if (result === void 0) { if (_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v)) { let _tmp1: (null) | undefined; _tmp1 = _.is(v.label, $atom) ? null : void 0; if (_tmp1 !== void 0) { let _tmp2: (AtomKind) | undefined; _tmp2 = toAtomKind(v[0]); if (_tmp2 !== void 0) {result = {"_variant": "atom", "atomKind": _tmp2};}; }; }; if (result === void 0) { if (_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v)) { let _tmp3: (null) | undefined; _tmp3 = _.is(v.label, $pointer) ? null : void 0; if (_tmp3 !== void 0) {result = {"_variant": "pointer"};}; }; if (result === void 0) { if (_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v)) { let _tmp4: (null) | undefined; _tmp4 = _.is(v.label, $lit) ? null : void 0; if (_tmp4 !== void 0) { let _tmp5: (_val) | undefined; _tmp5 = v[0]; if (_tmp5 !== void 0) {result = {"_variant": "lit", "value": _tmp5};}; }; }; if (result === void 0) { let _tmp6: (Ref) | undefined; _tmp6 = toRef(v); if (_tmp6 !== void 0) {result = {"_variant": "Ref", "value": _tmp6};}; }; }; }; }; return result; } export function asCompoundPattern(v: _val): CompoundPattern { let result = toCompoundPattern(v); if (result === void 0) throw new TypeError(`Invalid CompoundPattern: ${_.stringify(v)}`); return result; } export function toCompoundPattern(v: _val): undefined | CompoundPattern { let result: undefined | CompoundPattern; if (_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v)) { let _tmp0: (null) | undefined; _tmp0 = _.is(v.label, $rec) ? null : void 0; if (_tmp0 !== void 0) { let _tmp1: (NamedPattern) | undefined; _tmp1 = toNamedPattern(v[0]); if (_tmp1 !== void 0) { let _tmp2: (NamedPattern) | undefined; _tmp2 = toNamedPattern(v[1]); if (_tmp2 !== void 0) {result = {"_variant": "rec", "label": _tmp1, "fields": _tmp2};}; }; }; }; if (result === void 0) { if (_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v)) { let _tmp3: (null) | undefined; _tmp3 = _.is(v.label, $tuple) ? null : void 0; if (_tmp3 !== void 0) { if (_.Array.isArray(v[0])) { let _tmp4: (Array<_val>) | undefined; let _tmp5: (Array) | undefined; _tmp4 = v[0]; { _tmp5 = []; for (const _tmp6 of _tmp4) { let _tmp7: (NamedPattern) | undefined; _tmp7 = toNamedPattern(_tmp6); if (_tmp7 !== void 0) {_tmp5.push(_tmp7); continue;}; _tmp5 = void 0; break; }; if (_tmp5 !== void 0) {result = {"_variant": "tuple", "patterns": _tmp5};}; }; }; }; }; if (result === void 0) { if (_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v)) { let _tmp8: (null) | undefined; _tmp8 = _.is(v.label, $tuple$STAR$) ? null : void 0; if (_tmp8 !== void 0) { if (_.Array.isArray(v[0])) { let _tmp9: (Array<_val>) | undefined; let _tmp10: (Array) | undefined; _tmp9 = v[0]; { _tmp10 = []; for (const _tmp11 of _tmp9) { let _tmp12: (NamedPattern) | undefined; _tmp12 = toNamedPattern(_tmp11); if (_tmp12 !== void 0) {_tmp10.push(_tmp12); continue;}; _tmp10 = void 0; break; }; if (_tmp10 !== void 0) { let _tmp13: (NamedSimplePattern) | undefined; _tmp13 = toNamedSimplePattern(v[1]); if (_tmp13 !== void 0) {result = {"_variant": "tuple*", "fixed": _tmp10, "variable": _tmp13};}; }; }; }; }; }; if (result === void 0) { if (_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v)) { let _tmp14: (null) | undefined; _tmp14 = _.is(v.label, $setof) ? null : void 0; if (_tmp14 !== void 0) { let _tmp15: (SimplePattern) | undefined; _tmp15 = toSimplePattern(v[0]); if (_tmp15 !== void 0) {result = {"_variant": "setof", "pattern": _tmp15};}; }; }; if (result === void 0) { if (_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v)) { let _tmp16: (null) | undefined; _tmp16 = _.is(v.label, $dictof) ? null : void 0; if (_tmp16 !== void 0) { let _tmp17: (SimplePattern) | undefined; _tmp17 = toSimplePattern(v[0]); if (_tmp17 !== void 0) { let _tmp18: (SimplePattern) | undefined; _tmp18 = toSimplePattern(v[1]); if (_tmp18 !== void 0) {result = {"_variant": "dictof", "key": _tmp17, "value": _tmp18};}; }; }; }; if (result === void 0) { if (_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v)) { let _tmp19: (null) | undefined; _tmp19 = _.is(v.label, $dict) ? null : void 0; if (_tmp19 !== void 0) { let _tmp20: (DictionaryEntries) | undefined; _tmp20 = toDictionaryEntries(v[0]); if (_tmp20 !== void 0) {result = {"_variant": "dict", "entries": _tmp20};}; }; }; }; }; }; }; }; return result; } export function asDictionaryEntries(v: _val): DictionaryEntries { let result = toDictionaryEntries(v); if (result === void 0) throw new TypeError(`Invalid DictionaryEntries: ${_.stringify(v)}`); return result; } export function toDictionaryEntries(v: _val): undefined | DictionaryEntries { let _tmp0: (_.KeyedDictionary<_val, NamedSimplePattern, _ptr>) | undefined; let result: undefined | DictionaryEntries; if (_.Dictionary.isDictionary<_ptr>(v)) { _tmp0 = new _.KeyedDictionary(); for (const [_tmp2, _tmp1] of v) { let _tmp3: (_val) | undefined; _tmp3 = _tmp2; if (_tmp3 !== void 0) { let _tmp4: (NamedSimplePattern) | undefined; _tmp4 = toNamedSimplePattern(_tmp1); if (_tmp4 !== void 0) {_tmp0.set(_tmp3, _tmp4); continue;}; }; _tmp0 = void 0; break; }; if (_tmp0 !== void 0) {result = _tmp0;}; }; return result; } export function asAtomKind(v: _val): AtomKind { let result = toAtomKind(v); if (result === void 0) throw new TypeError(`Invalid AtomKind: ${_.stringify(v)}`); return result; } export function toAtomKind(v: _val): undefined | AtomKind { let _tmp0: (null) | undefined; let result: undefined | AtomKind; _tmp0 = _.is(v, $Boolean) ? null : void 0; if (_tmp0 !== void 0) {result = {"_variant": "Boolean"};}; if (result === void 0) { let _tmp1: (null) | undefined; _tmp1 = _.is(v, $Float) ? null : void 0; if (_tmp1 !== void 0) {result = {"_variant": "Float"};}; if (result === void 0) { let _tmp2: (null) | undefined; _tmp2 = _.is(v, $Double) ? null : void 0; if (_tmp2 !== void 0) {result = {"_variant": "Double"};}; if (result === void 0) { let _tmp3: (null) | undefined; _tmp3 = _.is(v, $SignedInteger) ? null : void 0; if (_tmp3 !== void 0) {result = {"_variant": "SignedInteger"};}; if (result === void 0) { let _tmp4: (null) | undefined; _tmp4 = _.is(v, $String) ? null : void 0; if (_tmp4 !== void 0) {result = {"_variant": "String"};}; if (result === void 0) { let _tmp5: (null) | undefined; _tmp5 = _.is(v, $ByteString) ? null : void 0; if (_tmp5 !== void 0) {result = {"_variant": "ByteString"};}; if (result === void 0) { let _tmp6: (null) | undefined; _tmp6 = _.is(v, $Symbol) ? null : void 0; if (_tmp6 !== void 0) {result = {"_variant": "Symbol"};}; }; }; }; }; }; }; return result; } export function asNamedSimplePattern(v: _val): NamedSimplePattern { let result = toNamedSimplePattern(v); if (result === void 0) throw new TypeError(`Invalid NamedSimplePattern: ${_.stringify(v)}`); return result; } export function toNamedSimplePattern(v: _val): undefined | NamedSimplePattern { let _tmp0: (NamedSimplePattern_) | undefined; let result: undefined | NamedSimplePattern; _tmp0 = toNamedSimplePattern_(v); if (_tmp0 !== void 0) {result = {"_variant": "named", "value": _tmp0};}; if (result === void 0) { let _tmp1: (SimplePattern) | undefined; _tmp1 = toSimplePattern(v); if (_tmp1 !== void 0) {result = {"_variant": "anonymous", "value": _tmp1};}; }; return result; } export function asNamedPattern(v: _val): NamedPattern { let result = toNamedPattern(v); if (result === void 0) throw new TypeError(`Invalid NamedPattern: ${_.stringify(v)}`); return result; } export function toNamedPattern(v: _val): undefined | NamedPattern { let _tmp0: (NamedSimplePattern_) | undefined; let result: undefined | NamedPattern; _tmp0 = toNamedSimplePattern_(v); if (_tmp0 !== void 0) {result = {"_variant": "named", "value": _tmp0};}; if (result === void 0) { let _tmp1: (Pattern) | undefined; _tmp1 = toPattern(v); if (_tmp1 !== void 0) {result = {"_variant": "anonymous", "value": _tmp1};}; }; return result; } export function asNamedSimplePattern_(v: _val): NamedSimplePattern_ { let result = toNamedSimplePattern_(v); if (result === void 0) throw new TypeError(`Invalid NamedSimplePattern_: ${_.stringify(v)}`); return result; } export function toNamedSimplePattern_(v: _val): undefined | NamedSimplePattern_ { let result: undefined | NamedSimplePattern_; if (_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v)) { let _tmp0: (null) | undefined; _tmp0 = _.is(v.label, $named) ? null : void 0; if (_tmp0 !== void 0) { let _tmp1: (symbol) | undefined; _tmp1 = typeof v[0] === 'symbol' ? v[0] : void 0; if (_tmp1 !== void 0) { let _tmp2: (SimplePattern) | undefined; _tmp2 = toSimplePattern(v[1]); if (_tmp2 !== void 0) {result = {"name": _tmp1, "pattern": _tmp2};}; }; }; }; return result; } export function asRef(v: _val): Ref { let result = toRef(v); if (result === void 0) throw new TypeError(`Invalid Ref: ${_.stringify(v)}`); return result; } export function toRef(v: _val): undefined | Ref { let result: undefined | Ref; if (_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v)) { let _tmp0: (null) | undefined; _tmp0 = _.is(v.label, $ref) ? null : void 0; if (_tmp0 !== void 0) { let _tmp1: (ModulePath) | undefined; _tmp1 = toModulePath(v[0]); if (_tmp1 !== void 0) { let _tmp2: (symbol) | undefined; _tmp2 = typeof v[1] === 'symbol' ? v[1] : void 0; if (_tmp2 !== void 0) {result = {"module": _tmp1, "name": _tmp2};}; }; }; }; return result; } export function asModulePath(v: _val): ModulePath { let result = toModulePath(v); if (result === void 0) throw new TypeError(`Invalid ModulePath: ${_.stringify(v)}`); return result; } export function toModulePath(v: _val): undefined | ModulePath { let result: undefined | ModulePath; if (_.Array.isArray(v)) { let _tmp0: (Array) | undefined; _tmp0 = []; for (const _tmp1 of v) { let _tmp2: (symbol) | undefined; _tmp2 = typeof _tmp1 === 'symbol' ? _tmp1 : void 0; if (_tmp2 !== void 0) {_tmp0.push(_tmp2); continue;}; _tmp0 = void 0; break; }; if (_tmp0 !== void 0) {result = _tmp0;}; }; return result; }