dope2/lib/values.js
2025-03-19 15:43:45 +01:00

39 lines
1.1 KiB
JavaScript

import {Int, Bool, Double, Byte} from "../primitives/symbols.js";
import { makeListModule } from "../structures/list_common.js";
import { makeProductType } from "../structures/product.js";
import { makeSumType } from "../structures/sum.js";
import { lsType, prodType, sumType } from "../type_registry.js";
const ListOfDouble = lsType(Double);
const ListOfDoubleModule = makeListModule(Double);
const ListOfListOfDouble = lsType(ListOfDouble);
const ListOfListOfDoubleModule = makeListModule(ListOfDouble);
const ListOfByte = lsType(Byte);
const ListOfByteModule = makeListModule(Byte);
export const ModuleValues = [
{i: 0n, t: Int},
{i: 42n, t: Int},
{i: false, t: Bool},
{i: 3.14159265359, t: Double},
{i: {l:[4.2, 7.6]} , t: ListOfDouble},
{i: {l:[{l:[4.2, 7.6]}, {l:[4.3]}]}, t: ListOfListOfDouble},
{i: new Uint8Array([1,2,3]), t: ListOfByte},
// i'm lazy
...ListOfDoubleModule,
...ListOfListOfDoubleModule,
...ListOfByteModule,
...makeProductType(Int, Bool),
...makeSumType(Int, Bool),
{i: {left: 42n, right: true}, t: prodType(Int, Bool)},
{i: {variant: "L", value: 100n}, t: sumType(Int, Bool)},
];