add primitive string type
This commit is contained in:
parent
aee8d5b5e1
commit
e2e9bbdccd
3 changed files with 5 additions and 29 deletions
|
|
@ -14,12 +14,14 @@ export const symbolType = "Type__fdbea309d66f49b483b0dd4ceb785f7d";
|
||||||
export const symbolTop = "⊤__38709c3c0039468782103256d4730d1f";
|
export const symbolTop = "⊤__38709c3c0039468782103256d4730d1f";
|
||||||
export const symbolDynamic = "Dynamic__3c16c415dba94228ada37dc9d446f54f";
|
export const symbolDynamic = "Dynamic__3c16c415dba94228ada37dc9d446f54f";
|
||||||
export const symbolOrdering = "Ordering__a11578cc83352023f16ffa2d060c52c2";
|
export const symbolOrdering = "Ordering__a11578cc83352023f16ffa2d060c52c2";
|
||||||
|
export const symbolString = "String__a32e9016b84ce5a9b5cde6dc35ccc99e";
|
||||||
|
|
||||||
export const Int = makeTypeConstructor(symbolInt)(0);
|
export const Int = makeTypeConstructor(symbolInt)(0);
|
||||||
export const Bool = makeTypeConstructor(symbolBool)(0);
|
export const Bool = makeTypeConstructor(symbolBool)(0);
|
||||||
export const Double = makeTypeConstructor(symbolDouble)(0);
|
export const Double = makeTypeConstructor(symbolDouble)(0);
|
||||||
export const Byte = makeTypeConstructor(symbolByte)(0);
|
export const Byte = makeTypeConstructor(symbolByte)(0);
|
||||||
export const Char = makeTypeConstructor(symbolChar)(0);
|
export const Char = makeTypeConstructor(symbolChar)(0);
|
||||||
|
export const String = makeTypeConstructor(symbolString)(0);
|
||||||
|
|
||||||
// Unit type has only 1 instance, the empty tuple.
|
// Unit type has only 1 instance, the empty tuple.
|
||||||
export const Unit = makeTypeConstructor(symbolUnit)(0);
|
export const Unit = makeTypeConstructor(symbolUnit)(0);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { newDynamic } from "./dynamic.js";
|
import { newDynamic } from "./dynamic.js";
|
||||||
import { symbolInt, UUID, symbolBool, symbolDouble, symbolByte, symbolChar, symbolUnit, symbolBottom, symbolUUID, symbolType, symbolTop, Type, Int, Bool, Double, Byte, Char, Unit, Bottom, Top, symbolDynamic, Dynamic, symbolOrdering, Ordering } from "./primitive_types.js";
|
import { symbolInt, UUID, symbolBool, symbolDouble, symbolByte, symbolChar, symbolUnit, symbolBottom, symbolUUID, symbolType, symbolTop, Type, Int, Bool, Double, Byte, Char, Unit, Bottom, Top, symbolDynamic, Dynamic, symbolOrdering, Ordering, symbolString } from "./primitive_types.js";
|
||||||
|
|
||||||
export const ModulePrimitiveSymbols = [
|
export const ModulePrimitiveSymbols = [
|
||||||
["symbolInt" , newDynamic(symbolInt )(UUID)],
|
["symbolInt" , newDynamic(symbolInt )(UUID)],
|
||||||
|
|
@ -14,6 +14,7 @@ export const ModulePrimitiveSymbols = [
|
||||||
["symbolTop" , newDynamic(symbolTop )(UUID)],
|
["symbolTop" , newDynamic(symbolTop )(UUID)],
|
||||||
["symbolDynamic" , newDynamic(symbolDynamic )(UUID)],
|
["symbolDynamic" , newDynamic(symbolDynamic )(UUID)],
|
||||||
["symbolOrdering", newDynamic(symbolOrdering)(UUID)],
|
["symbolOrdering", newDynamic(symbolOrdering)(UUID)],
|
||||||
|
["symbolString" , newDynamic(symbolString )(UUID)],
|
||||||
];
|
];
|
||||||
|
|
||||||
export const ModulePrimitiveTypes = [
|
export const ModulePrimitiveTypes = [
|
||||||
|
|
@ -29,4 +30,5 @@ export const ModulePrimitiveTypes = [
|
||||||
["Top" , newDynamic(Top )(Type)],
|
["Top" , newDynamic(Top )(Type)],
|
||||||
["Dynamic" , newDynamic(Dynamic )(Type)],
|
["Dynamic" , newDynamic(Dynamic )(Type)],
|
||||||
["Ordering", newDynamic(Ordering)(Type)],
|
["Ordering", newDynamic(Ordering)(Type)],
|
||||||
|
["String" , newDynamic(String )(Type)],
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -5,34 +5,6 @@ import { makeConstructors, makeMatchFn } from "./enum.js";
|
||||||
import { getLeft, getRight } from "./product.js";
|
import { getLeft, getRight } from "./product.js";
|
||||||
import { fnType } from "./type_constructors.types.js";
|
import { fnType } from "./type_constructors.types.js";
|
||||||
|
|
||||||
// 'variants' is an array of (name: string, type: Type) pairs.
|
|
||||||
// e.g., the list of variants:
|
|
||||||
// [ { l: "price" , r: Int },
|
|
||||||
// { l: "prices" , r: [Int] },
|
|
||||||
// { l: "not_found", r: Unit } ]
|
|
||||||
// results in the type:
|
|
||||||
// (Int | ([Int] | (Unit | ⊥)))
|
|
||||||
|
|
||||||
// const _enumType = rootSelf => variants => {
|
|
||||||
// // console.log("enumType..", variants);
|
|
||||||
// if (variants.length === 0) {
|
|
||||||
// return Bottom; // empty enum is equal to Bottom-type (cannot be instantiated)
|
|
||||||
// }
|
|
||||||
// const [variant, ...rest] = variants;
|
|
||||||
// const variantType = getRight(variant);
|
|
||||||
// return sumType
|
|
||||||
// (self => {
|
|
||||||
// // console.log("requested left type (of enumType)")
|
|
||||||
// return variantType(rootSelf || self);
|
|
||||||
// })
|
|
||||||
// (self => {
|
|
||||||
// // console.log("requested right type (of enumType)")
|
|
||||||
// return _enumType(self)(rest)
|
|
||||||
// });
|
|
||||||
// };
|
|
||||||
|
|
||||||
// export const enumType = _enumType(null);
|
|
||||||
|
|
||||||
export const makeConstructorTypes = type => variants => {
|
export const makeConstructorTypes = type => variants => {
|
||||||
return variants.map(variant => {
|
return variants.map(variant => {
|
||||||
const variantType = getRight(variant);
|
const variantType = getRight(variant);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue