dope2/primitives/types.js
Joeri Exelmans 8eec5b9239 recursive types (and operations on them, like pretty-printing, comparison and unification) seem to be working.
big part of the code base still needs to be 'ported' to the updated type constructors.
2025-05-05 17:17:45 +02:00

51 lines
1.9 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// to break up dependency cycles, primitive types are defined in their own JS module
import { makeTypeConstructor } from "../type_constructor.js";
export const SymbolInt = Symbol('Int');
export const SymbolBool = Symbol('Bool');
export const SymbolDouble = Symbol('Double');
export const SymbolByte = Symbol('Byte');
export const SymbolChar = Symbol('Char');
export const SymbolUnit = Symbol('Unit');
export const SymbolBottom = Symbol('⊥');
export const SymbolSymbol = Symbol('Symbol');
export const SymbolType = Symbol('Type');
export const symbolTop = Symbol('');
export const SymbolGenericType = Symbol('GenericType');
export const Int = makeTypeConstructor(SymbolInt)(0);
export const Bool = makeTypeConstructor(SymbolBool)(0);
export const Double = makeTypeConstructor(SymbolDouble)(0);
export const Byte = makeTypeConstructor(SymbolByte)(0);
export const Char = makeTypeConstructor(SymbolChar)(0);
// Unit type has only 1 instance, the empty tuple.
export const Unit = makeTypeConstructor(SymbolUnit)(0);
// Bottom type has no instances.
export const Bottom = makeTypeConstructor(SymbolBottom)(0);
export const SymbolT = makeTypeConstructor(SymbolSymbol)(0);
// Types are typed by Top
export const Type = makeTypeConstructor(SymbolType)(0);
export const GenericType = makeTypeConstructor(SymbolGenericType)(0);
// Everything is typed by Top
export const Top = makeTypeConstructor(symbolTop)(0);
export const ModuleSymbols = {l:[
{i: SymbolInt , t: SymbolT},
{i: SymbolBool , t: SymbolT},
{i: SymbolDouble , t: SymbolT},
{i: SymbolByte , t: SymbolT},
{i: SymbolChar , t: SymbolT},
{i: SymbolUnit , t: SymbolT},
{i: SymbolBottom , t: SymbolT},
{i: SymbolSymbol , t: SymbolT},
{i: SymbolType , t: SymbolT},
{i: SymbolGenericType, t: SymbolT},
{i: symbolTop , t: SymbolT},
]};