Add product and sum types
This commit is contained in:
parent
6023efc295
commit
574651ccb7
18 changed files with 209 additions and 157 deletions
33
lib/values.js
Normal file
33
lib/values.js
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import {Int, Bool, Double} from "../primitives/symbols.js";
|
||||
import { makeListModule } from "../structures/list_common.js";
|
||||
import { makeProductType } from "../structures/product.js";
|
||||
import { makeSumType } from "../structures/sum.js";
|
||||
import { getListType, prodType, sumType } from "../type_registry.js";
|
||||
|
||||
const ListOfInt = getListType(Int);
|
||||
const ListOfIntModule = makeListModule(Int);
|
||||
|
||||
const ListOfListOfInt = getListType(ListOfInt);
|
||||
const ListOfListOfIntModule = makeListModule(ListOfInt);
|
||||
|
||||
export const ModuleValues = [
|
||||
{i: 0n, t: Int},
|
||||
{i: 42n, t: Int},
|
||||
{i: false, t: Bool},
|
||||
{i: 3.14159265359, t: Double},
|
||||
|
||||
{i: {l:[42n, 43n]} , t: ListOfInt},
|
||||
{i: {l:[{l:[42n, 43n]}, {l:[999n]}]}, t: ListOfListOfInt},
|
||||
|
||||
// i'm lazy
|
||||
...ListOfIntModule,
|
||||
...ListOfListOfIntModule,
|
||||
|
||||
|
||||
...makeProductType(Int, Bool),
|
||||
|
||||
...makeSumType(Int, Bool),
|
||||
|
||||
{i: {left: 42n, right: true}, t: prodType(Int, Bool)},
|
||||
{i: {variant: "L", value: 100n}, t: sumType(Int, Bool)},
|
||||
];
|
||||
Loading…
Add table
Add a link
Reference in a new issue