diff --git a/builtin.mjs b/builtin.mjs index b5dc85d..e63ccbf 100644 --- a/builtin.mjs +++ b/builtin.mjs @@ -52,6 +52,7 @@ const snd = (_, args) => [args[0].snd]; const eq = (_, args) => { if (args[0].type === args[1].type && args[0].val === args[1].val) { + console.log(args[0], args[1]) return [{type:"ident", val:"true"}]; } else { return [{type:"ident", val:"false"}]; @@ -92,7 +93,7 @@ addDefn("snd", ["pair"], snd); addDefn("arr", ["int"], arr); addDefn("!!", ["int", "array"], index); addDefn("len", ["array"], len); -addDefn("coerce", 2, coerce); +addDefn("unsafeCoerce", 2, coerce); //addRPNDefn("unit", "(-> 0 arr)"); //addRPNDefn("mono", "(-> 1 arr)"); //addRPNDefn("unwrap", "(-> 0 !!)"); diff --git a/index.html b/index.html index f9109ec..90b3581 100644 --- a/index.html +++ b/index.html @@ -33,9 +33,10 @@ can call fst and snd on pairs

Type Literals

Essentialy strings.
-Example useage: "1 "int coerce 1 + +Example useage: "1 "int unsafeCoerce 1 +

Equality

Internaly JS-based, derived for all objects, pushes lambdas representing true and false onto the stack. +
For example: "true-option "false-option val1 val2 ==

Examples

factorial: (!; x -> 1 '(-> x 1 - ! x *) x 0 ==) diff --git a/parse.mjs b/parse.mjs index c653a56..7e2474a 100644 --- a/parse.mjs +++ b/parse.mjs @@ -145,12 +145,11 @@ const parseName = (stream) => { } const parseType = (stream) => { - let syn = attempt(parseSyntax("\""))(stream); if (syn.parsed === null) { return {parsed:null, stream:syn.stream}; } - let id = parseIdent(syn.stream); + let id = or(parseIdent, parseInteger)(syn.stream); if (id.parsed === null) { return {parsed:null, stream:id.stream}; }