fez-lisp 1.6.85 → 1.6.89
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/baked/std-T.js +1 -1
- package/package.json +1 -1
- package/src/check.js +221 -88
- package/src/types.js +8 -1
- package/src/utils.js +57 -56
package/lib/baked/std-T.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export default [[[0,"the"],[1,"math:reverse"],[[0,"lambda"],[1,"Number[]"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"math:map"],[[0,"lambda"],[1,"Number[]"],[[0,"lambda"],[1,"Number"],[[0,"do"],[1,"Number"]]],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"math:select"],[[0,"lambda"],[1,"Number[]"],[[0,"lambda"],[1,"Number"],[[0,"do"],[1,"Boolean"]]],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"math:exclude"],[[0,"lambda"],[1,"Number[]"],[[0,"lambda"],[1,"Number"],[[0,"do"],[1,"Boolean"]]],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"math:fold"],[[0,"lambda"],[1,"Number[]"],[[0,"lambda"],[1,"Number"],[1,"Number"],[[0,"do"],[1,"Number"]]],[1,"Number"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"math:enumerated-map"],[[0,"lambda"],[1,"Number[]"],[[0,"lambda"],[1,"Number"],[1,"Number"],[[0,"do"],[1,"Number"]]],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"math:enumerated-fold"],[[0,"lambda"],[1,"Number[]"],[[0,"lambda"],[1,"Number"],[1,"Number"],[1,"Number"],[[0,"do"],[1,"Number"]]],[1,"Number"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"math:every?"],[[0,"lambda"],[1,"Number[]"],[[0,"lambda"],[1,"Number"],[[0,"do"],[1,"Boolean"]]],[[0,"do"],[1,"Boolean"]]]],[[0,"the"],[1,"math:some?"],[[0,"lambda"],[1,"Number[]"],[[0,"lambda"],[1,"Number"],[[0,"do"],[1,"Boolean"]]],[[0,"do"],[1,"Boolean"]]]],[[0,"the"],[1,"math:enumerated-every?"],[[0,"lambda"],[1,"Number[]"],[[0,"lambda"],[1,"Number"],[1,"Number"],[[0,"do"],[1,"Boolean"]]],[[0,"do"],[1,"Boolean"]]]],[[0,"the"],[1,"math:enumerated-some?"],[[0,"lambda"],[1,"Number[]"],[[0,"lambda"],[1,"Number"],[1,"Number"],[[0,"do"],[1,"Boolean"]]],[[0,"do"],[1,"Boolean"]]]],[[0,"the"],[1,"math:enumerated-select"],[[0,"lambda"],[1,"Number[]"],[[0,"lambda"],[1,"Number"],[1,"Number"],[[0,"do"],[1,"Boolean"]]],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"math:enumerated-exclude"],[[0,"lambda"],[1,"Number[]"],[[0,"lambda"],[1,"Number"],[1,"Number"],[[0,"do"],[1,"Boolean"]]],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"math:log-taylor-series"],[[0,"lambda"],[1,"Number"],[1,"Number"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"math:collatz"],[[0,"lambda"],[1,"Number"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"math:maximum-index"],[[0,"lambda"],[1,"Number[]"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"math:minimum-index"],[[0,"lambda"],[1,"Number[]"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"math:var-def"],[[0,"lambda"],[1,"Number"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"math:var-get"],[[0,"lambda"],[1,"Number[]"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"math:var-set!"],[[0,"lambda"],[1,"Number[]"],[1,"Number"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"math:var-del!"],[[0,"lambda"],[1,"Number[]"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"math:var-set-and-get!"],[[0,"lambda"],[1,"Number[]"],[1,"Number"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"math:var-increment!"],[[0,"lambda"],[1,"Number[]"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"math:var-decrement!"],[[0,"lambda"],[1,"Number[]"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"math:var-increment-and-get!"],[[0,"lambda"],[1,"Number[]"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"math:var-decrement-and-get!"],[[0,"lambda"],[1,"Number[]"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"math:var-add!"],[[0,"lambda"],[1,"Number[]"],[1,"Number"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"math:var-subtract!"],[[0,"lambda"],[1,"Number[]"],[1,"Number"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"math:var-multiply!"],[[0,"lambda"],[1,"Number[]"],[1,"Number"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"math:var-divide!"],[[0,"lambda"],[1,"Number[]"],[1,"Number"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"math:var-add-and-get!"],[[0,"lambda"],[1,"Number[]"],[1,"Number"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"math:var-subtract-and-get!"],[[0,"lambda"],[1,"Number[]"],[1,"Number"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"math:var-multiply-and-get!"],[[0,"lambda"],[1,"Number[]"],[1,"Number"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"math:var-divide-and-get!"],[[0,"lambda"],[1,"Number[]"],[1,"Number"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"math:max-sub-array-sum"],[[0,"lambda"],[1,"Number[]"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"math:median"],[[0,"lambda"],[1,"Number[]"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"math:mean"],[[0,"lambda"],[1,"Number[]"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"math:subset"],[[0,"lambda"],[1,"Unknown[]"],[[0,"do"],[1,"Unknown[][]"]]]],[[0,"the"],[1,"math:permutations"],[[0,"lambda"],[1,"Unknown[]"],[[0,"do"],[1,"Unknown[][]"]]]],[[0,"the"],[1,"math:combinations"],[[0,"lambda"],[1,"Unknown[]"],[[0,"do"],[1,"Unknown[][]"]]]],[[0,"the"],[1,"math:combinations-n"],[[0,"lambda"],[1,"Unknown[]"],[1,"Number"],[[0,"do"],[1,"Unknown[][]"]]]],[[0,"the"],[1,"math:variants"],[[0,"lambda"],[1,"Unknown[]"],[1,"Number"],[[0,"do"],[1,"Unknown[][]"]]]],[[0,"the"],[1,"math:unique"],[[0,"lambda"],[1,"Number[]"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"math:divisors"],[[0,"lambda"],[1,"Number"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"math:remove-leading-zeroes"],[[0,"lambda"],[1,"Number[]"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"math:sort"],[[0,"lambda"],[1,"Number[]"],[[0,"lambda"],[1,"Number"],[1,"Number"],[[0,"do"],[1,"Boolean"]]],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"math:flat-one"],[[0,"lambda"],[1,"Number[][]"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"matrix:zeroes"],[[0,"lambda"],[1,"Number"],[1,"Number"],[[0,"do"],[1,"Number[][]"]]]],[[0,"the"],[1,"matrix:ones"],[[0,"lambda"],[1,"Number"],[1,"Number"],[[0,"do"],[1,"Number[][]"]]]],[[0,"the"],[1,"matrix:find-index"],[[0,"lambda"],[1,"Unknown[]"],[[0,"lambda"],[1,"Unknown"],[[0,"do"],[1,"Boolean"]]],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"matrix:points"],[[0,"lambda"],[1,"Unknown[]"],[[0,"lambda"],[1,"Unknown"],[[0,"do"],[1,"Boolean"]]],[[0,"do"],[1,"Number[][]"]]]],[[0,"the"],[1,"var:def"],[[0,"lambda"],[1,"Any"],[[0,"do"],[1,"Unknown[]"]]]],[[0,"the"],[1,"var:get"],[[0,"lambda"],[1,"Unknown[]"],[[0,"do"],[1,"Any"]]]],[[0,"the"],[1,"var:set!"],[[0,"lambda"],[1,"Unknown[]"],[1,"Any"],[[0,"do"],[1,"Unknown[]"]]]],[[0,"the"],[1,"var:del!"],[[0,"lambda"],[1,"Unknown[]"],[[0,"do"],[1,"Unknown[]"]]]],[[0,"the"],[1,"var:set-and-get!"],[[0,"lambda"],[1,"Unknown[]"],[1,"Any"],[[0,"do"],[1,"Any"]]]],[[0,"the"],[1,"array:first"],[[0,"lambda"],[1,"Unknown[]"],[[0,"do"],[1,"Any"]]]],[[0,"the"],[1,"array:second"],[[0,"lambda"],[1,"Unknown[]"],[[0,"do"],[1,"Any"]]]],[[0,"the"],[1,"array:third"],[[0,"lambda"],[1,"Unknown[]"],[[0,"do"],[1,"Any"]]]],[[0,"the"],[1,"array:last"],[[0,"lambda"],[1,"Unknown[]"],[[0,"do"],[1,"Any"]]]],[[0,"the"],[1,"array:get"],[[0,"lambda"],[1,"Unknown[]"],[1,"Number"],[[0,"do"],[1,"Any"]]]],[[0,"the"],[1,"array:get-number"],[[0,"lambda"],[1,"Number[]"],[1,"Number"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"array:get-nested-number-1"],[[0,"lambda"],[1,"Number[][]"],[1,"Number"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"array:get-nested-number-2"],[[0,"lambda"],[1,"Number[][][]"],[1,"Number"],[[0,"do"],[1,"Number[][]"]]]],[[0,"the"],[1,"array:get-array"],[[0,"lambda"],[1,"Unknown[][]"],[1,"Number"],[[0,"do"],[1,"Unknown[]"]]]],[[0,"the"],[1,"array:get-nested-array-1"],[[0,"lambda"],[1,"Unknown[][]"],[1,"Number"],[[0,"do"],[1,"Unknown[]"]]]],[[0,"the"],[1,"array:get-nested-array-2"],[[0,"lambda"],[1,"Unknown[][][]"],[1,"Number"],[[0,"do"],[1,"Unknown[][]"]]]],[[0,"the"],[1,"array:get-boolean"],[[0,"lambda"],[1,"Boolean[]"],[1,"Number"],[[0,"do"],[1,"Boolean"]]]],[[0,"the"],[1,"array:get-nested-boolean-1"],[[0,"lambda"],[1,"Boolean[][]"],[1,"Number"],[[0,"do"],[1,"Boolean[]"]]]],[[0,"the"],[1,"array:get-nested-boolean-2"],[[0,"lambda"],[1,"Boolean[][][]"],[1,"Number"],[[0,"do"],[1,"Boolean[][]"]]]],[[0,"the"],[1,"array:transform"],[[0,"lambda"],[1,"Unknown[]"],[[0,"lambda"],[1,"Unknown[]"],[1,"Unknown"],[[0,"do"],[1,"Unknown"]]],[1,"Unknown[]"],[[0,"do"],[1,"Unknown[]"]]]],[[0,"the"],[1,"array:reduce"],[[0,"lambda"],[1,"Unknown[]"],[[0,"lambda"],[1,"Number"],[1,"Unknown"],[[0,"do"],[1,"Number"]]],[1,"Number"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"array:enumerated-reduce"],[[0,"lambda"],[1,"Unknown[]"],[[0,"lambda"],[1,"Number"],[1,"Unknown"],[1,"Number"],[[0,"do"],[1,"Number"]]],[1,"Number"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"array:zip"],[[0,"lambda"],[1,"Unknown[]"],[1,"Unknown[]"],[[0,"do"],[1,"Unknown[][]"]]]],[[0,"the"],[1,"array:unzip"],[[0,"lambda"],[1,"Unknown[]"],[[0,"do"],[1,"Unknown[][]"]]]],[[0,"the"],[1,"array:set!"],[[0,"lambda"],[1,"Unknown[]"],[1,"Number"],[1,"Any"],[[0,"do"],[1,"Unknown[]"]]]],[[0,"the"],[1,"array:push!"],[[0,"lambda"],[1,"Unknown[]"],[1,"Any"],[[0,"do"],[1,"Any"]]]],[[0,"the"],[1,"array:append!"],[[0,"lambda"],[1,"Unknown[]"],[1,"Any"],[[0,"do"],[1,"Unknown[]"]]]],[[0,"the"],[1,"array:fold"],[[0,"lambda"],[1,"Unknown[]"],[[0,"lambda"],[1,"Unknown"],[1,"Unknown"],[[0,"do"],[1,"Any"]]],[1,"Unknown"],[[0,"do"],[1,"Unknown"]]]],[[0,"the"],[1,"list:fold"],[[0,"lambda"],[1,"Unknown[]"],[[0,"lambda"],[1,"Unknown"],[1,"Unknown"],[[0,"do"],[1,"Any"]]],[1,"Unknown"],[[0,"do"],[1,"Unknown"]]]],[[0,"the"],[1,"bools:fold"],[[0,"lambda"],[1,"Boolean[]"],[[0,"lambda"],[1,"Boolean"],[1,"Boolean"],[[0,"do"],[1,"Boolean"]]],[1,"Boolean"],[[0,"do"],[1,"Boolean"]]]],[[0,"the"],[1,"bools:map"],[[0,"lambda"],[1,"Boolean[]"],[[0,"lambda"],[1,"Boolean"],[[0,"do"],[1,"Boolean"]]],[[0,"do"],[1,"Boolean[]"]]]],[[0,"the"],[1,"bools:select"],[[0,"lambda"],[1,"Boolean[]"],[[0,"lambda"],[1,"Boolean"],[[0,"do"],[1,"Boolean"]]],[[0,"do"],[1,"Boolean[]"]]]],[[0,"the"],[1,"bools:exclude"],[[0,"lambda"],[1,"Boolean[]"],[[0,"lambda"],[1,"Boolean"],[[0,"do"],[1,"Boolean"]]],[[0,"do"],[1,"Boolean[]"]]]],[[0,"the"],[1,"boole:def-strict"],[[0,"lambda"],[1,"Boolean"],[[0,"do"],[1,"Boolean[]"]]]],[[0,"the"],[1,"boole:get"],[[0,"lambda"],[1,"Boolean[]"],[[0,"do"],[1,"Boolean"]]]],[[0,"the"],[1,"boole:set!"],[[0,"lambda"],[1,"Boolean[]"],[1,"Boolean"],[[0,"do"],[1,"Boolean[]"]]]],[[0,"the"],[1,"boole:toggle!"],[[0,"lambda"],[1,"Boolean[]"],[[0,"do"],[1,"Boolean[]"]]]],[[0,"the"],[1,"boole:true!"],[[0,"lambda"],[1,"Boolean[]"],[[0,"do"],[1,"Boolean[]"]]]],[[0,"the"],[1,"boole:false!"],[[0,"lambda"],[1,"Boolean[]"],[[0,"do"],[1,"Boolean[]"]]]],[[0,"the"],[1,"boole:true?"],[[0,"lambda"],[1,"Boolean[]"],[[0,"do"],[1,"Boolean"]]]],[[0,"the"],[1,"boole:false?"],[[0,"lambda"],[1,"Boolean[]"],[[0,"do"],[1,"Boolean"]]]],[[0,"the"],[1,"from:string->array"],[[0,"lambda"],[1,"Number[]"],[1,"Number"],[[0,"do"],[1,"Unknown[][]"]]]],[[0,"the"],[1,"from:array->string"],[[0,"lambda"],[1,"Unknown[][]"],[1,"Number"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"from:strings->integers"],[[0,"lambda"],[1,"Unknown[][]"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"from:string->integer"],[[0,"lambda"],[1,"Number[]"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"from:integer->string"],[[0,"lambda"],[1,"Number"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"from:strings->floats"],[[0,"lambda"],[1,"Unknown[][]"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"from:string->float"],[[0,"lambda"],[1,"Number[]"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"from:float->string"],[[0,"lambda"],[1,"Number"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"from:chars->digits"],[[0,"lambda"],[1,"Number[]"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"from:digits->chars"],[[0,"lambda"],[1,"Number[]"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"from:digits->integer"],[[0,"lambda"],[1,"Number[]"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"from:integer->digits"],[[0,"lambda"],[1,"Number"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"from:chars->set"],[[0,"lambda"],[1,"Number[]"],[[0,"do"],[1,"Number[][]"]]]]]
|
1
|
+
export default [[[0,"the"],[1,"math:reverse"],[[0,"lambda"],[1,"Number[]"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"math:map"],[[0,"lambda"],[1,"Number[]"],[[0,"lambda"],[1,"Number"],[[0,"do"],[1,"Number"]]],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"math:select"],[[0,"lambda"],[1,"Number[]"],[[0,"lambda"],[1,"Number"],[[0,"do"],[1,"Boolean"]]],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"math:exclude"],[[0,"lambda"],[1,"Number[]"],[[0,"lambda"],[1,"Number"],[[0,"do"],[1,"Boolean"]]],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"math:fold"],[[0,"lambda"],[1,"Number[]"],[[0,"lambda"],[1,"Number"],[1,"Number"],[[0,"do"],[1,"Number"]]],[1,"Number"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"math:enumerated-map"],[[0,"lambda"],[1,"Number[]"],[[0,"lambda"],[1,"Number"],[1,"Number"],[[0,"do"],[1,"Number"]]],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"math:enumerated-fold"],[[0,"lambda"],[1,"Number[]"],[[0,"lambda"],[1,"Number"],[1,"Number"],[1,"Number"],[[0,"do"],[1,"Number"]]],[1,"Number"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"math:every?"],[[0,"lambda"],[1,"Number[]"],[[0,"lambda"],[1,"Number"],[[0,"do"],[1,"Boolean"]]],[[0,"do"],[1,"Boolean"]]]],[[0,"the"],[1,"math:some?"],[[0,"lambda"],[1,"Number[]"],[[0,"lambda"],[1,"Number"],[[0,"do"],[1,"Boolean"]]],[[0,"do"],[1,"Boolean"]]]],[[0,"the"],[1,"math:enumerated-every?"],[[0,"lambda"],[1,"Number[]"],[[0,"lambda"],[1,"Number"],[1,"Number"],[[0,"do"],[1,"Boolean"]]],[[0,"do"],[1,"Boolean"]]]],[[0,"the"],[1,"math:enumerated-some?"],[[0,"lambda"],[1,"Number[]"],[[0,"lambda"],[1,"Number"],[1,"Number"],[[0,"do"],[1,"Boolean"]]],[[0,"do"],[1,"Boolean"]]]],[[0,"the"],[1,"math:enumerated-select"],[[0,"lambda"],[1,"Number[]"],[[0,"lambda"],[1,"Number"],[1,"Number"],[[0,"do"],[1,"Boolean"]]],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"math:enumerated-exclude"],[[0,"lambda"],[1,"Number[]"],[[0,"lambda"],[1,"Number"],[1,"Number"],[[0,"do"],[1,"Boolean"]]],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"math:log-taylor-series"],[[0,"lambda"],[1,"Number"],[1,"Number"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"math:collatz"],[[0,"lambda"],[1,"Number"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"math:maximum-index"],[[0,"lambda"],[1,"Number[]"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"math:minimum-index"],[[0,"lambda"],[1,"Number[]"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"math:var-def"],[[0,"lambda"],[1,"Number"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"math:var-get"],[[0,"lambda"],[1,"Number[]"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"math:var-set!"],[[0,"lambda"],[1,"Number[]"],[1,"Number"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"math:var-del!"],[[0,"lambda"],[1,"Number[]"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"math:var-set-and-get!"],[[0,"lambda"],[1,"Number[]"],[1,"Number"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"math:var-increment!"],[[0,"lambda"],[1,"Number[]"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"math:var-decrement!"],[[0,"lambda"],[1,"Number[]"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"math:var-increment-and-get!"],[[0,"lambda"],[1,"Number[]"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"math:var-decrement-and-get!"],[[0,"lambda"],[1,"Number[]"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"math:var-add!"],[[0,"lambda"],[1,"Number[]"],[1,"Number"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"math:var-subtract!"],[[0,"lambda"],[1,"Number[]"],[1,"Number"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"math:var-multiply!"],[[0,"lambda"],[1,"Number[]"],[1,"Number"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"math:var-divide!"],[[0,"lambda"],[1,"Number[]"],[1,"Number"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"math:var-add-and-get!"],[[0,"lambda"],[1,"Number[]"],[1,"Number"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"math:var-subtract-and-get!"],[[0,"lambda"],[1,"Number[]"],[1,"Number"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"math:var-multiply-and-get!"],[[0,"lambda"],[1,"Number[]"],[1,"Number"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"math:var-divide-and-get!"],[[0,"lambda"],[1,"Number[]"],[1,"Number"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"math:max-sub-array-sum"],[[0,"lambda"],[1,"Number[]"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"math:median"],[[0,"lambda"],[1,"Number[]"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"math:mean"],[[0,"lambda"],[1,"Number[]"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"math:subset"],[[0,"lambda"],[1,"Unknown[]"],[[0,"do"],[1,"Unknown[][]"]]]],[[0,"the"],[1,"math:permutations"],[[0,"lambda"],[1,"Unknown[]"],[[0,"do"],[1,"Unknown[][]"]]]],[[0,"the"],[1,"math:combinations"],[[0,"lambda"],[1,"Unknown[]"],[[0,"do"],[1,"Unknown[][]"]]]],[[0,"the"],[1,"math:combinations-n"],[[0,"lambda"],[1,"Unknown[]"],[1,"Number"],[[0,"do"],[1,"Unknown[][]"]]]],[[0,"the"],[1,"math:variants"],[[0,"lambda"],[1,"Unknown[]"],[1,"Number"],[[0,"do"],[1,"Unknown[][]"]]]],[[0,"the"],[1,"math:unique"],[[0,"lambda"],[1,"Number[]"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"math:divisors"],[[0,"lambda"],[1,"Number"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"math:remove-leading-zeroes"],[[0,"lambda"],[1,"Number[]"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"math:sort"],[[0,"lambda"],[1,"Number[]"],[[0,"lambda"],[1,"Number"],[1,"Number"],[[0,"do"],[1,"Boolean"]]],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"math:flat-one"],[[0,"lambda"],[1,"Number[][]"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"matrix:zeroes"],[[0,"lambda"],[1,"Number"],[1,"Number"],[[0,"do"],[1,"Number[][]"]]]],[[0,"the"],[1,"matrix:ones"],[[0,"lambda"],[1,"Number"],[1,"Number"],[[0,"do"],[1,"Number[][]"]]]],[[0,"the"],[1,"matrix:find-index"],[[0,"lambda"],[1,"Unknown[]"],[[0,"lambda"],[1,"Unknown"],[[0,"do"],[1,"Boolean"]]],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"matrix:points"],[[0,"lambda"],[1,"Unknown[]"],[[0,"lambda"],[1,"Unknown"],[[0,"do"],[1,"Boolean"]]],[[0,"do"],[1,"Number[][]"]]]],[[0,"the"],[1,"var:def"],[[0,"lambda"],[1,"Any"],[[0,"do"],[1,"Unknown[]"]]]],[[0,"the"],[1,"var:get"],[[0,"lambda"],[1,"Unknown[]"],[[0,"do"],[1,"Any"]]]],[[0,"the"],[1,"var:set!"],[[0,"lambda"],[1,"Unknown[]"],[1,"Any"],[[0,"do"],[1,"Unknown[]"]]]],[[0,"the"],[1,"var:del!"],[[0,"lambda"],[1,"Unknown[]"],[[0,"do"],[1,"Unknown[]"]]]],[[0,"the"],[1,"var:set-and-get!"],[[0,"lambda"],[1,"Unknown[]"],[1,"Any"],[[0,"do"],[1,"Any"]]]],[[0,"the"],[1,"array:first"],[[0,"lambda"],[1,"Unknown[]"],[[0,"do"],[1,"Any"]]]],[[0,"the"],[1,"array:second"],[[0,"lambda"],[1,"Unknown[]"],[[0,"do"],[1,"Any"]]]],[[0,"the"],[1,"array:third"],[[0,"lambda"],[1,"Unknown[]"],[[0,"do"],[1,"Any"]]]],[[0,"the"],[1,"array:last"],[[0,"lambda"],[1,"Unknown[]"],[[0,"do"],[1,"Any"]]]],[[0,"the"],[1,"array:get"],[[0,"lambda"],[1,"Unknown[]"],[1,"Number"],[[0,"do"],[1,"Any"]]]],[[0,"the"],[1,"array:get-number"],[[0,"lambda"],[1,"Number[]"],[1,"Number"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"array:get-nested-number-1"],[[0,"lambda"],[1,"Number[][]"],[1,"Number"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"array:get-nested-number-2"],[[0,"lambda"],[1,"Number[][][]"],[1,"Number"],[[0,"do"],[1,"Number[][]"]]]],[[0,"the"],[1,"array:get-array"],[[0,"lambda"],[1,"Unknown[][]"],[1,"Number"],[[0,"do"],[1,"Unknown[]"]]]],[[0,"the"],[1,"array:get-nested-array-1"],[[0,"lambda"],[1,"Unknown[][]"],[1,"Number"],[[0,"do"],[1,"Unknown[]"]]]],[[0,"the"],[1,"array:get-nested-array-2"],[[0,"lambda"],[1,"Unknown[][][]"],[1,"Number"],[[0,"do"],[1,"Unknown[][]"]]]],[[0,"the"],[1,"array:get-boolean"],[[0,"lambda"],[1,"Boolean[]"],[1,"Number"],[[0,"do"],[1,"Boolean"]]]],[[0,"the"],[1,"array:get-nested-boolean-1"],[[0,"lambda"],[1,"Boolean[][]"],[1,"Number"],[[0,"do"],[1,"Boolean[]"]]]],[[0,"the"],[1,"array:get-nested-boolean-2"],[[0,"lambda"],[1,"Boolean[][][]"],[1,"Number"],[[0,"do"],[1,"Boolean[][]"]]]],[[0,"the"],[1,"array:transform"],[[0,"lambda"],[1,"Unknown[]"],[[0,"lambda"],[1,"Unknown[]"],[1,"Unknown"],[[0,"do"],[1,"Unknown"]]],[1,"Unknown[]"],[[0,"do"],[1,"Unknown[]"]]]],[[0,"the"],[1,"array:reduce"],[[0,"lambda"],[1,"Unknown[]"],[[0,"lambda"],[1,"Number"],[1,"Unknown"],[[0,"do"],[1,"Number"]]],[1,"Number"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"array:enumerated-reduce"],[[0,"lambda"],[1,"Unknown[]"],[[0,"lambda"],[1,"Number"],[1,"Unknown"],[1,"Number"],[[0,"do"],[1,"Number"]]],[1,"Number"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"array:zip"],[[0,"lambda"],[1,"Unknown[]"],[1,"Unknown[]"],[[0,"do"],[1,"Unknown[][]"]]]],[[0,"the"],[1,"array:unzip"],[[0,"lambda"],[1,"Unknown[]"],[[0,"do"],[1,"Unknown[][]"]]]],[[0,"the"],[1,"array:set!"],[[0,"lambda"],[1,"Unknown[]"],[1,"Number"],[1,"Any"],[[0,"do"],[1,"Unknown[]"]]]],[[0,"the"],[1,"array:push!"],[[0,"lambda"],[1,"Unknown[]"],[1,"Any"],[[0,"do"],[1,"Any"]]]],[[0,"the"],[1,"array:append!"],[[0,"lambda"],[1,"Unknown[]"],[1,"Any"],[[0,"do"],[1,"Unknown[]"]]]],[[0,"the"],[1,"array:fold"],[[0,"lambda"],[1,"Unknown[]"],[[0,"lambda"],[1,"Unknown"],[1,"Unknown"],[[0,"do"],[1,"Any"]]],[1,"Unknown"],[[0,"do"],[1,"Unknown"]]]],[[0,"the"],[1,"list:fold"],[[0,"lambda"],[1,"Unknown[]"],[[0,"lambda"],[1,"Unknown"],[1,"Unknown"],[[0,"do"],[1,"Any"]]],[1,"Unknown"],[[0,"do"],[1,"Unknown"]]]],[[0,"the"],[1,"bools:fold"],[[0,"lambda"],[1,"Boolean[]"],[[0,"lambda"],[1,"Boolean"],[1,"Boolean"],[[0,"do"],[1,"Boolean"]]],[1,"Boolean"],[[0,"do"],[1,"Boolean"]]]],[[0,"the"],[1,"bools:map"],[[0,"lambda"],[1,"Boolean[]"],[[0,"lambda"],[1,"Boolean"],[[0,"do"],[1,"Boolean"]]],[[0,"do"],[1,"Boolean[]"]]]],[[0,"the"],[1,"bools:select"],[[0,"lambda"],[1,"Boolean[]"],[[0,"lambda"],[1,"Boolean"],[[0,"do"],[1,"Boolean"]]],[[0,"do"],[1,"Boolean[]"]]]],[[0,"the"],[1,"bools:exclude"],[[0,"lambda"],[1,"Boolean[]"],[[0,"lambda"],[1,"Boolean"],[[0,"do"],[1,"Boolean"]]],[[0,"do"],[1,"Boolean[]"]]]],[[0,"the"],[1,"boole:def-strict"],[[0,"lambda"],[1,"Boolean"],[[0,"do"],[1,"Boolean[]"]]]],[[0,"the"],[1,"boole:get"],[[0,"lambda"],[1,"Boolean[]"],[[0,"do"],[1,"Boolean"]]]],[[0,"the"],[1,"boole:set!"],[[0,"lambda"],[1,"Boolean[]"],[1,"Boolean"],[[0,"do"],[1,"Boolean[]"]]]],[[0,"the"],[1,"boole:toggle!"],[[0,"lambda"],[1,"Boolean[]"],[[0,"do"],[1,"Boolean[]"]]]],[[0,"the"],[1,"boole:true!"],[[0,"lambda"],[1,"Boolean[]"],[[0,"do"],[1,"Boolean[]"]]]],[[0,"the"],[1,"boole:false!"],[[0,"lambda"],[1,"Boolean[]"],[[0,"do"],[1,"Boolean[]"]]]],[[0,"the"],[1,"boole:true?"],[[0,"lambda"],[1,"Boolean[]"],[[0,"do"],[1,"Boolean"]]]],[[0,"the"],[1,"boole:false?"],[[0,"lambda"],[1,"Boolean[]"],[[0,"do"],[1,"Boolean"]]]],[[0,"the"],[1,"from:string->array"],[[0,"lambda"],[1,"Number[]"],[1,"Number"],[[0,"do"],[1,"Unknown[][]"]]]],[[0,"the"],[1,"from:array->string"],[[0,"lambda"],[1,"Unknown[][]"],[1,"Number"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"from:strings->integers"],[[0,"lambda"],[1,"Unknown[][]"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"from:string->integer"],[[0,"lambda"],[1,"Number[]"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"from:integer->string"],[[0,"lambda"],[1,"Number"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"from:strings->floats"],[[0,"lambda"],[1,"Unknown[][]"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"from:string->float"],[[0,"lambda"],[1,"Number[]"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"from:float->string"],[[0,"lambda"],[1,"Number"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"from:chars->digits"],[[0,"lambda"],[1,"Number[]"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"from:digits->chars"],[[0,"lambda"],[1,"Number[]"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"from:digits->integer"],[[0,"lambda"],[1,"Number[]"],[[0,"do"],[1,"Number"]]]],[[0,"the"],[1,"from:integer->digits"],[[0,"lambda"],[1,"Number"],[[0,"do"],[1,"Number[]"]]]],[[0,"the"],[1,"from:chars->set"],[[0,"lambda"],[1,"Number[]"],[[0,"do"],[1,"Number[][]"]]]],[[0,"the"],[1,"identity"],[[0,"lambda"],[1,"T"],[[0,"do"],[1,"T"]]]]]
|
package/package.json
CHANGED
package/src/check.js
CHANGED
@@ -47,7 +47,9 @@ import {
|
|
47
47
|
NUMBER_SUBTYPE,
|
48
48
|
SubType,
|
49
49
|
GET_ARRAY_INFERENCE_SET,
|
50
|
-
GENERIC
|
50
|
+
GENERIC,
|
51
|
+
TYPE_NAME,
|
52
|
+
RETURN_NAME
|
51
53
|
} from './types.js'
|
52
54
|
import {
|
53
55
|
Brr,
|
@@ -58,6 +60,7 @@ import {
|
|
58
60
|
logExp,
|
59
61
|
stringifyArgs,
|
60
62
|
wrapInApplyLambda,
|
63
|
+
wrapInArray,
|
61
64
|
wrapInBlock
|
62
65
|
} from './utils.js'
|
63
66
|
|
@@ -110,6 +113,8 @@ export const isGenericReturn = (stats) =>
|
|
110
113
|
stats[RETURNS].length === 3 && stats[RETURNS][2][0] !== -1
|
111
114
|
export const isGenericType = (stats) =>
|
112
115
|
stats[TYPE_PROP].length === 3 && stats[TYPE_PROP][2][0] !== -1
|
116
|
+
export const isGenericProp = (stats, prop) =>
|
117
|
+
stats[prop].length === 3 && stats[prop][2][0] !== -1
|
113
118
|
|
114
119
|
export const isTypeAbstraction = (stats) => stats[TYPE_PROP] === APPLY
|
115
120
|
export const setPropToAtom = (stats, prop) => {
|
@@ -340,6 +345,69 @@ const isRedefinedInLambda = (env, name, exp) => {
|
|
340
345
|
return true
|
341
346
|
else return false
|
342
347
|
}
|
348
|
+
const getGenericPropNest = (ref, prop) =>
|
349
|
+
ref[STATS][prop][0] === COLLECTION
|
350
|
+
? isSubType(ref[STATS][prop][1])
|
351
|
+
? ref[STATS][prop][1].nestedLevels()
|
352
|
+
: 0
|
353
|
+
: 0
|
354
|
+
const getGenericProp = (ref, rem, prop) => {
|
355
|
+
const [index, multiplier] = ref[STATS][prop][2]
|
356
|
+
const generic = rem.slice(1)[index]
|
357
|
+
const nestGeneric = getGenericPropNest(ref, prop)
|
358
|
+
return [
|
359
|
+
generic,
|
360
|
+
isLeaf(generic) ? generic : generic[0],
|
361
|
+
nestGeneric,
|
362
|
+
multiplier
|
363
|
+
]
|
364
|
+
}
|
365
|
+
const getGenericReturn = (ref, rem) => getGenericProp(ref, rem, RETURNS)
|
366
|
+
const getGenericType = (ref, rem) => getGenericProp(ref, rem, TYPE_PROP)
|
367
|
+
const resolveGenericNest = (ref, prop, nestGeneric, multiplier) => {
|
368
|
+
const hasSubType = isSubType(ref[STATS][prop][1])
|
369
|
+
const T = hasSubType ? ref[STATS][prop][1].types : [ref[STATS][prop][0]]
|
370
|
+
if (multiplier === -1) {
|
371
|
+
if (nestGeneric === 0) {
|
372
|
+
if (T.at(-1) === NUMBER || T.at(-1) === BOOLEAN) {
|
373
|
+
if (hasSubType) {
|
374
|
+
if (ref[STATS][prop][1].types.length === 1) ref[STATS][prop][0] = ATOM
|
375
|
+
else {
|
376
|
+
ref[STATS][prop][1] = new SubType(
|
377
|
+
ref[STATS][prop][1].types.slice(1)
|
378
|
+
)
|
379
|
+
ref[STATS][prop][0] = COLLECTION
|
380
|
+
ref[STATS][prop].length = 2
|
381
|
+
}
|
382
|
+
} else ref[STATS][prop][0] = ATOM
|
383
|
+
}
|
384
|
+
} else {
|
385
|
+
if (T.length - nestGeneric - 1) {
|
386
|
+
if (hasSubType)
|
387
|
+
for (let i = 0; i < nestGeneric + 1; ++i)
|
388
|
+
ref[STATS][prop][1].types.shift()
|
389
|
+
ref[STATS][prop].length = 2
|
390
|
+
} else {
|
391
|
+
if (T.at(-1) === NUMBER || T.at(-1) === BOOLEAN) {
|
392
|
+
ref[STATS][prop][0] = ATOM
|
393
|
+
ref[STATS][prop][1] = new SubType([T.at(-1)])
|
394
|
+
ref[STATS][prop].length = 2
|
395
|
+
} else {
|
396
|
+
ref[STATS][prop][0] = APPLY
|
397
|
+
ref[STATS][prop].length = 1
|
398
|
+
}
|
399
|
+
}
|
400
|
+
}
|
401
|
+
} else if (multiplier === 1) {
|
402
|
+
const st = new SubType([])
|
403
|
+
for (let i = 0; i < nestGeneric; ++i) st.add(COLLECTION)
|
404
|
+
if (ref[STATS][prop][0] === COLLECTION) st.add(COLLECTION)
|
405
|
+
st.add(...T)
|
406
|
+
ref[STATS][prop][0] = COLLECTION
|
407
|
+
ref[STATS][prop][1] = st
|
408
|
+
}
|
409
|
+
}
|
410
|
+
|
343
411
|
export const equalReturns = (a, b) =>
|
344
412
|
isAnyReturn(a) || isAnyReturn(b) || a[RETURNS][0] === b[RETURNS][0]
|
345
413
|
export const equalsTypeWithReturn = (a, b) =>
|
@@ -470,6 +538,12 @@ const once = (stats, ctx, stack, cb, method = 'prepend') => {
|
|
470
538
|
stagger(stack, method, ctx, cb)
|
471
539
|
}
|
472
540
|
}
|
541
|
+
const doOnce = (stats, ctx, stack, cb, method = 'prepend') => {
|
542
|
+
if (!stats.tried) {
|
543
|
+
stats.tried = true
|
544
|
+
stagger(stack, method, ctx, cb)
|
545
|
+
}
|
546
|
+
}
|
473
547
|
const retryArgs = (stats, ctx, stack, cb) => {
|
474
548
|
if (stats.counter < MAX_ARGUMENT_RETRY) {
|
475
549
|
stats.counter++
|
@@ -1023,18 +1097,9 @@ const resolveReturnType = ({
|
|
1023
1097
|
// Here is upon application to store the result in the variable
|
1024
1098
|
if (isGenericReturn(env[returns[VALUE]][STATS])) {
|
1025
1099
|
// env[name][STATS][TYPE_PROP] =
|
1026
|
-
const [index, multiplier] = env[returns[VALUE]][STATS][RETURNS][2]
|
1027
|
-
const genericReturn = rem.slice(1)[index]
|
1028
|
-
const nestGeneric =
|
1029
|
-
env[returns[VALUE]][STATS][RETURNS][0] === COLLECTION
|
1030
|
-
? isSubType(env[returns[VALUE]][STATS][RETURNS][1])
|
1031
|
-
? env[returns[VALUE]][STATS][RETURNS][1].nestedLevels()
|
1032
|
-
: 0
|
1033
|
-
: 0
|
1034
1100
|
|
1035
|
-
const head =
|
1036
|
-
|
1037
|
-
: genericReturn[0]
|
1101
|
+
const [genericReturn, head, nestGeneric, multiplier] =
|
1102
|
+
getGenericReturn(env[returns[VALUE]], rem)
|
1038
1103
|
|
1039
1104
|
switch (head[TYPE]) {
|
1040
1105
|
case ATOM:
|
@@ -1102,47 +1167,9 @@ const resolveReturnType = ({
|
|
1102
1167
|
setTypeToReturn(env[name][STATS], env[head[VALUE]][STATS])
|
1103
1168
|
break
|
1104
1169
|
}
|
1170
|
+
|
1105
1171
|
if (env[returns[VALUE]][STATS][RETURNS][0] === COLLECTION) {
|
1106
|
-
|
1107
|
-
? env[name][STATS][prop][1].types
|
1108
|
-
: [env[name][STATS][prop][0]]
|
1109
|
-
if (multiplier === -1) {
|
1110
|
-
if (nestGeneric === 0) {
|
1111
|
-
if (T.at(-1) === NUMBER || T.at(-1) === BOOLEAN) {
|
1112
|
-
if (isSubType(env[name][STATS][prop][1])) {
|
1113
|
-
if (env[name][STATS][prop][1].types.length === 1)
|
1114
|
-
env[name][STATS][prop][0] = ATOM
|
1115
|
-
else {
|
1116
|
-
env[name][STATS][prop][1] = new SubType(
|
1117
|
-
env[name][STATS][prop][1].types.slice(1)
|
1118
|
-
)
|
1119
|
-
env[name][STATS][prop][0] = COLLECTION
|
1120
|
-
}
|
1121
|
-
} else env[name][STATS][prop][0] = ATOM
|
1122
|
-
}
|
1123
|
-
} else {
|
1124
|
-
if (T.length - nestGeneric - 1) {
|
1125
|
-
for (let i = 0; i < nestGeneric + 1; ++i)
|
1126
|
-
env[name][STATS][prop][1].types.shift()
|
1127
|
-
} else {
|
1128
|
-
if (T.at(-1) === NUMBER || T.at(-1) === BOOLEAN) {
|
1129
|
-
env[name][STATS][prop][0] = ATOM
|
1130
|
-
env[name][STATS][prop][1] = new SubType([T.at(-1)])
|
1131
|
-
} else {
|
1132
|
-
env[name][STATS][prop][0] = APPLY
|
1133
|
-
env[name][STATS][prop].length = 1
|
1134
|
-
}
|
1135
|
-
}
|
1136
|
-
}
|
1137
|
-
} else {
|
1138
|
-
const st = new SubType([])
|
1139
|
-
for (let i = 0; i < nestGeneric; ++i) st.add(COLLECTION)
|
1140
|
-
if (env[name][STATS][prop][0] === COLLECTION)
|
1141
|
-
st.add(COLLECTION)
|
1142
|
-
st.add(...T)
|
1143
|
-
env[name][STATS][prop][0] = COLLECTION
|
1144
|
-
env[name][STATS][prop][1] = st
|
1145
|
-
}
|
1172
|
+
resolveGenericNest(env[name], prop, nestGeneric, multiplier)
|
1146
1173
|
}
|
1147
1174
|
}
|
1148
1175
|
if (isUnknownType(env[name][STATS]))
|
@@ -1264,6 +1291,8 @@ export const typeCheck = (
|
|
1264
1291
|
const match1 = () => {
|
1265
1292
|
const actual = local[lambdaName]
|
1266
1293
|
const expected = args[i]
|
1294
|
+
if (isGenericReturn(expected[STATS])) return
|
1295
|
+
|
1267
1296
|
// if (
|
1268
1297
|
// isGenericReturn(args[i][STATS]) &&
|
1269
1298
|
// !isUnknownReturn(actual[STATS]) &&
|
@@ -1314,6 +1343,7 @@ export const typeCheck = (
|
|
1314
1343
|
for (let j = 0; j < args[i][STATS][ARGUMENTS].length; ++j) {
|
1315
1344
|
const actual = local[lambdaName][STATS][ARGUMENTS][j]
|
1316
1345
|
const expected = args[i][STATS][ARGUMENTS][j]
|
1346
|
+
if (isGenericType(expected[STATS])) continue
|
1317
1347
|
// TODO: after refactoring the generic nesting and unnesting logic
|
1318
1348
|
// apply it here to judge lambda arguments based on the signature
|
1319
1349
|
// if (
|
@@ -1324,7 +1354,6 @@ export const typeCheck = (
|
|
1324
1354
|
// expected[STATS][TYPE_PROP] = actual[STATS][TYPE_PROP]
|
1325
1355
|
// return
|
1326
1356
|
// }
|
1327
|
-
|
1328
1357
|
if (
|
1329
1358
|
!isUnknownType(actual[STATS]) &&
|
1330
1359
|
!isUnknownType(expected[STATS]) &&
|
@@ -1855,9 +1884,9 @@ export const typeCheck = (
|
|
1855
1884
|
}
|
1856
1885
|
}
|
1857
1886
|
}
|
1887
|
+
|
1858
1888
|
// also type of arg
|
1859
1889
|
const args = env[first[VALUE]][STATS][ARGUMENTS] ?? []
|
1860
|
-
const generics = Array.from(args).fill(null)
|
1861
1890
|
for (let i = 0; i < args.length; ++i) {
|
1862
1891
|
// type check
|
1863
1892
|
// TODO get rof pred type
|
@@ -1961,8 +1990,6 @@ export const typeCheck = (
|
|
1961
1990
|
)}) (${stringifyArgs(exp)}) (check #203)`
|
1962
1991
|
)
|
1963
1992
|
}
|
1964
|
-
if (isGenericType(args[i][STATS]))
|
1965
|
-
generics[i] = [ATOM]
|
1966
1993
|
break
|
1967
1994
|
case APPLY:
|
1968
1995
|
{
|
@@ -2032,12 +2059,6 @@ export const typeCheck = (
|
|
2032
2059
|
setTypeRef(env[name][STATS], args[i][STATS])
|
2033
2060
|
else setStatsRef(env[rest[i][VALUE]], args[i])
|
2034
2061
|
}
|
2035
|
-
if (
|
2036
|
-
isGenericType(args[i][STATS]) &&
|
2037
|
-
!isUnknownNotAnyType(env[name][STATS])
|
2038
|
-
) {
|
2039
|
-
generics[i] = env[name][STATS][TYPE_PROP]
|
2040
|
-
}
|
2041
2062
|
}
|
2042
2063
|
if (isUnknownType(args[i][STATS])) {
|
2043
2064
|
retry(args[i][STATS], [first, env], stack, () =>
|
@@ -2058,11 +2079,8 @@ export const typeCheck = (
|
|
2058
2079
|
isUnknownReturn(env[name][STATS]) &&
|
2059
2080
|
!env[name][STATS][IS_ARGUMENT]
|
2060
2081
|
)
|
2061
|
-
|
2062
|
-
env
|
2063
|
-
[first, env],
|
2064
|
-
stack,
|
2065
|
-
() => check(exp, env, scope)
|
2082
|
+
retry(env[name][STATS], [first, env], stack, () =>
|
2083
|
+
check(exp, env, scope)
|
2066
2084
|
)
|
2067
2085
|
else if (
|
2068
2086
|
env[name] &&
|
@@ -2083,46 +2101,161 @@ export const typeCheck = (
|
|
2083
2101
|
break
|
2084
2102
|
}
|
2085
2103
|
match({ rest, args, i, env, scope, exp })
|
2086
|
-
|
2087
|
-
if (
|
2088
|
-
isGenericType(args[i][STATS]) &&
|
2089
|
-
!isUnknownNotAnyReturn(env[name][STATS])
|
2090
|
-
)
|
2091
|
-
generics[i] = env[name][STATS][RETURNS]
|
2092
2104
|
}
|
2093
2105
|
}
|
2094
2106
|
}
|
2095
|
-
|
2107
|
+
// GENERICS CODE START
|
2108
|
+
if (
|
2109
|
+
first[VALUE][0] !== PLACEHOLDER &&
|
2110
|
+
env[first[VALUE]][STATS][ARGUMENTS] &&
|
2111
|
+
env[first[VALUE]][STATS][ARGUMENTS].length &&
|
2112
|
+
env[first[VALUE]][STATS].source &&
|
2113
|
+
env[first[VALUE]][STATS][ARGUMENTS].some(
|
2114
|
+
(x) => isGenericType(x[STATS]) || isGenericReturn(x[STATS])
|
2115
|
+
)
|
2116
|
+
) {
|
2117
|
+
const rec = (ref) => {
|
2118
|
+
if (isGenericReturn(ref[STATS])) {
|
2119
|
+
const [index, multiplier] = ref[STATS][RETURNS][2]
|
2120
|
+
const desiredTypeIndex = env[first[VALUE]][STATS][
|
2121
|
+
ARGUMENTS
|
2122
|
+
].findIndex(
|
2123
|
+
(x) => x[STATS][TYPE_NAME] === ref[STATS][RETURN_NAME]
|
2124
|
+
)
|
2125
|
+
const isCollection = ref[STATS][RETURNS][0] === COLLECTION
|
2126
|
+
if (desiredTypeIndex !== -1) {
|
2127
|
+
const desiredType = isLeaf(rest[desiredTypeIndex])
|
2128
|
+
? rest[desiredTypeIndex]
|
2129
|
+
: rest[desiredTypeIndex][0]
|
2130
|
+
switch (desiredType[TYPE]) {
|
2131
|
+
case ATOM:
|
2132
|
+
ref[STATS][RETURNS] = [ATOM, NUMBER_SUBTYPE()]
|
2133
|
+
break
|
2134
|
+
case WORD:
|
2135
|
+
ref[STATS][RETURNS][0] =
|
2136
|
+
env[desiredType[VALUE]][STATS][TYPE_PROP][0]
|
2137
|
+
ref[STATS][RETURNS][1] =
|
2138
|
+
env[desiredType[VALUE]][STATS][TYPE_PROP][1]
|
2139
|
+
break
|
2140
|
+
case APPLY:
|
2141
|
+
switch (desiredType[VALUE]) {
|
2142
|
+
case KEYWORDS.CREATE_ARRAY:
|
2143
|
+
ref[STATS][RETURNS] = initArrayType({
|
2144
|
+
rem: rest[desiredTypeIndex],
|
2145
|
+
env
|
2146
|
+
})[RETURNS]
|
2147
|
+
break
|
2148
|
+
default:
|
2149
|
+
ref[STATS][RETURNS] =
|
2150
|
+
env[desiredType[VALUE]][STATS][RETURNS]
|
2151
|
+
break
|
2152
|
+
}
|
2153
|
+
break
|
2154
|
+
default:
|
2155
|
+
break
|
2156
|
+
}
|
2157
|
+
if (isCollection) {
|
2158
|
+
const nest = getGenericPropNest(
|
2159
|
+
env[desiredType[VALUE]],
|
2160
|
+
TYPE_PROP
|
2161
|
+
)
|
2162
|
+
resolveGenericNest(ref, RETURNS, nest, multiplier)
|
2163
|
+
}
|
2164
|
+
ref[STATS][RETURNS].length = 2
|
2165
|
+
}
|
2166
|
+
}
|
2167
|
+
const args = ref[STATS][ARGUMENTS]
|
2168
|
+
for (const expected of args) {
|
2169
|
+
if (isGenericType(expected[STATS])) {
|
2170
|
+
const [index, multiplier] =
|
2171
|
+
expected[STATS][TYPE_PROP][2]
|
2172
|
+
const desiredTypeIndex = env[first[VALUE]][STATS][
|
2173
|
+
ARGUMENTS
|
2174
|
+
].findIndex(
|
2175
|
+
(x) =>
|
2176
|
+
x[STATS][TYPE_NAME] === expected[STATS][TYPE_NAME]
|
2177
|
+
)
|
2178
|
+
if (desiredTypeIndex !== -1) {
|
2179
|
+
const desiredType = isLeaf(rest[desiredTypeIndex])
|
2180
|
+
? rest[desiredTypeIndex]
|
2181
|
+
: rest[desiredTypeIndex][0]
|
2182
|
+
switch (desiredType[TYPE]) {
|
2183
|
+
case ATOM:
|
2184
|
+
expected[STATS][TYPE_PROP] = [
|
2185
|
+
ATOM,
|
2186
|
+
NUMBER_SUBTYPE()
|
2187
|
+
]
|
2188
|
+
break
|
2189
|
+
case WORD:
|
2190
|
+
expected[STATS][TYPE_PROP][0] =
|
2191
|
+
env[desiredType[VALUE]][STATS][TYPE_PROP][0]
|
2192
|
+
expected[STATS][TYPE_PROP][1] =
|
2193
|
+
env[desiredType[VALUE]][STATS][TYPE_PROP][1]
|
2194
|
+
break
|
2195
|
+
case APPLY:
|
2196
|
+
switch (desiredType[VALUE]) {
|
2197
|
+
case KEYWORDS.CREATE_ARRAY:
|
2198
|
+
expected[STATS][TYPE_PROP] = initArrayType({
|
2199
|
+
rem: rest[desiredTypeIndex],
|
2200
|
+
env
|
2201
|
+
})[RETURNS]
|
2202
|
+
break
|
2203
|
+
default:
|
2204
|
+
expected[STATS][ARG_COUNT] =
|
2205
|
+
env[desiredType[VALUE]][STATS][ARG_COUNT]
|
2206
|
+
expected[STATS][TYPE_PROP][0] =
|
2207
|
+
env[desiredType[VALUE]][STATS][RETURNS][0]
|
2208
|
+
expected[STATS][TYPE_PROP][1] =
|
2209
|
+
env[desiredType[VALUE]][STATS][RETURNS][1]
|
2210
|
+
break
|
2211
|
+
}
|
2212
|
+
break
|
2213
|
+
default:
|
2214
|
+
break
|
2215
|
+
}
|
2216
|
+
if (expected[STATS][TYPE_PROP][0] === COLLECTION) {
|
2217
|
+
const nest = getGenericPropNest(
|
2218
|
+
env[desiredType[VALUE]],
|
2219
|
+
TYPE_PROP
|
2220
|
+
)
|
2221
|
+
|
2222
|
+
resolveGenericNest(
|
2223
|
+
expected,
|
2224
|
+
TYPE_PROP,
|
2225
|
+
nest,
|
2226
|
+
multiplier === 1 ? 0 : multiplier
|
2227
|
+
)
|
2228
|
+
}
|
2229
|
+
expected[STATS][TYPE_PROP].length = 2
|
2230
|
+
}
|
2231
|
+
}
|
2232
|
+
if (expected[STATS][ARGUMENTS].length) rec(expected)
|
2233
|
+
}
|
2234
|
+
}
|
2096
2235
|
const copy = Object.create(env)
|
2097
2236
|
const newName = `${PLACEHOLDER}${first[VALUE]}`
|
2098
|
-
|
2237
|
+
copy[newName] = null
|
2099
2238
|
copy[newName] = {
|
2100
2239
|
[STATS]: structuredClone(env[first[VALUE]][STATS])
|
2101
2240
|
}
|
2102
|
-
|
2103
|
-
|
2104
|
-
|
2105
|
-
|
2106
|
-
[ARG_COUNT]: VARIADIC,
|
2107
|
-
[ARGUMENTS]: [],
|
2108
|
-
[TYPE_PROP]: generics[i],
|
2109
|
-
[RETURNS]: generics[i]
|
2110
|
-
}
|
2111
|
-
}
|
2112
|
-
}
|
2241
|
+
copy[newName][STATS][SIGNATURE] = newName
|
2242
|
+
|
2243
|
+
rec(copy[newName])
|
2244
|
+
|
2113
2245
|
const cexp = structuredClone(exp)
|
2114
2246
|
copy[newName][STATS].source = structuredClone(
|
2115
2247
|
copy[newName][STATS].source
|
2116
2248
|
)
|
2117
2249
|
cexp[0][VALUE] = newName
|
2118
2250
|
copy[newName][STATS].source[1][VALUE] = newName
|
2119
|
-
|
2251
|
+
doOnce(copy[newName][STATS], cexp, stack, () => {
|
2120
2252
|
check(
|
2121
|
-
|
2253
|
+
wrapInArray([copy[newName][STATS].source, cexp]),
|
2122
2254
|
copy,
|
2123
2255
|
scope
|
2124
2256
|
)
|
2125
2257
|
})
|
2258
|
+
// GENERICS END END
|
2126
2259
|
return
|
2127
2260
|
}
|
2128
2261
|
}
|
package/src/types.js
CHANGED
@@ -23,6 +23,8 @@ export const RETURNS = 'returns'
|
|
23
23
|
export const SCOPE_NAME = '__scope__'
|
24
24
|
export const TYPE_PROP = 'type'
|
25
25
|
export const SIGNATURE = 'name'
|
26
|
+
export const TYPE_NAME = 'type_name'
|
27
|
+
export const RETURN_NAME = 'return_name'
|
26
28
|
export const UNBOUND_VARIABLE = '__unbound__'
|
27
29
|
export const UNKNOWN = -1
|
28
30
|
export const COLLECTION = 3
|
@@ -1508,6 +1510,8 @@ export const toArgType = (A, i) => {
|
|
1508
1510
|
[IS_ARGUMENT]: true,
|
1509
1511
|
[SIGNATURE]: PLACEHOLDER,
|
1510
1512
|
[TYPE_PROP]: [APPLY],
|
1513
|
+
[TYPE_NAME]: PLACEHOLDER,
|
1514
|
+
[RETURN_NAME]: returns[VALUE].replaceAll('[', '').replaceAll(']', ''),
|
1511
1515
|
[RETURNS]: toTypeCodes(returns[VALUE], i),
|
1512
1516
|
[ARGUMENTS]: args.map(toArgType).flat(1),
|
1513
1517
|
[ARG_COUNT]: args.length
|
@@ -1519,7 +1523,8 @@ export const toArgType = (A, i) => {
|
|
1519
1523
|
argIndex: i,
|
1520
1524
|
retried: Infinity,
|
1521
1525
|
[IS_ARGUMENT]: true,
|
1522
|
-
[SIGNATURE]:
|
1526
|
+
[SIGNATURE]: PLACEHOLDER,
|
1527
|
+
[TYPE_NAME]: arg[VALUE].replaceAll('[', '').replaceAll(']', ''),
|
1523
1528
|
[TYPE_PROP]: toTypeCodes(arg[VALUE], i),
|
1524
1529
|
[RETURNS]: toTypeCodes(arg[VALUE], i),
|
1525
1530
|
[ARGUMENTS]: [],
|
@@ -1539,6 +1544,8 @@ export const fromSourceToType = (T) => {
|
|
1539
1544
|
retried: Infinity,
|
1540
1545
|
[TYPE_PROP]: [APPLY],
|
1541
1546
|
[SIGNATURE]: name,
|
1547
|
+
[TYPE_NAME]: name,
|
1548
|
+
[RETURN_NAME]: returns[VALUE].replaceAll('[', '').replaceAll(']', ''),
|
1542
1549
|
[ARG_COUNT]: args.length,
|
1543
1550
|
[ARGUMENTS]: args.map(toArgType).flat(1),
|
1544
1551
|
[RETURNS]: toTypeCodes(
|
package/src/utils.js
CHANGED
@@ -297,6 +297,7 @@ export const dfs = (tree, callback) => {
|
|
297
297
|
if (!isLeaf(tree)) for (const leaf of tree) dfs(leaf)
|
298
298
|
else callback(tree)
|
299
299
|
}
|
300
|
+
export const wrapInArray = (ast) => [[APPLY, KEYWORDS.CREATE_ARRAY], ...ast]
|
300
301
|
export const wrapInBlock = (ast) => [
|
301
302
|
[APPLY, KEYWORDS.CALL_FUNCTION],
|
302
303
|
[
|
@@ -389,63 +390,63 @@ export const init = () => {
|
|
389
390
|
// console.log('Added file types.lisp in src')
|
390
391
|
writeFileSync(
|
391
392
|
'index.js',
|
392
|
-
`import { compile, enhance, parse, LISP, UTILS, verify } from '
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
}
|
402
|
-
UTILS.logResult(LISP.serialise(evaluated))
|
403
|
-
} else UTILS.logError(error.message)
|
404
|
-
} catch (error) {
|
405
|
-
UTILS.logError(error.message)
|
406
|
-
}
|
407
|
-
}
|
408
|
-
export const run = (source) => {
|
409
|
-
try {
|
410
|
-
const parsed = parse(source)
|
411
|
-
const { evaluated, error } = UTILS.debug(parsed, false)
|
412
|
-
if (error == null) {
|
413
|
-
UTILS.logResult(LISP.serialise(evaluated))
|
414
|
-
} else UTILS.logError(error.message)
|
415
|
-
} catch (error) {
|
416
|
-
UTILS.logError(error.message)
|
417
|
-
}
|
418
|
-
}
|
419
|
-
export const check = (source, types) => {
|
420
|
-
try {
|
421
|
-
const parsed = parse(source)
|
422
|
-
const error = verify(parsed, types)
|
423
|
-
if (error != null) UTILS.logError(error)
|
424
|
-
} catch (error) {
|
425
|
-
UTILS.logError(error.message)
|
426
|
-
}
|
393
|
+
`import { compile, enhance, parse, LISP, UTILS, verify } from 'fez-lisp'
|
394
|
+
import { readFileSync, writeFileSync } from 'fs'
|
395
|
+
export const dev = (source, types) => {
|
396
|
+
try {
|
397
|
+
const parsed = parse(source)
|
398
|
+
const { evaluated, type, error } = UTILS.debug(parsed, true, types)
|
399
|
+
if (error == null) {
|
400
|
+
if (type) {
|
401
|
+
UTILS.logType(type)
|
427
402
|
}
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
403
|
+
UTILS.logResult(LISP.serialise(evaluated))
|
404
|
+
} else UTILS.logError(error.message)
|
405
|
+
} catch (error) {
|
406
|
+
UTILS.logError(error.message)
|
407
|
+
}
|
408
|
+
}
|
409
|
+
export const run = (source) => {
|
410
|
+
try {
|
411
|
+
const parsed = parse(source)
|
412
|
+
const { evaluated, error } = UTILS.debug(parsed, false)
|
413
|
+
if (error == null) {
|
414
|
+
UTILS.logResult(LISP.serialise(evaluated))
|
415
|
+
} else UTILS.logError(error.message)
|
416
|
+
} catch (error) {
|
417
|
+
UTILS.logError(error.message)
|
418
|
+
}
|
419
|
+
}
|
420
|
+
export const check = (source, types) => {
|
421
|
+
try {
|
422
|
+
const parsed = parse(source)
|
423
|
+
const error = verify(parsed, types)
|
424
|
+
if (error != null) UTILS.logError(error)
|
425
|
+
} catch (error) {
|
426
|
+
UTILS.logError(error.message)
|
427
|
+
}
|
428
|
+
}
|
429
|
+
export const comp = (source) => compile(enhance(parse(source)))
|
430
|
+
const file = readFileSync('./src/main.lisp', 'utf-8')
|
431
|
+
const [src, typ] = UTILS.extractTypes(file)
|
432
|
+
switch (process.argv[2]) {
|
433
|
+
case 'check':
|
434
|
+
check(src, typ)
|
435
|
+
break
|
436
|
+
case 'run':
|
437
|
+
run(src, typ)
|
438
|
+
break
|
439
|
+
case 'comp':
|
440
|
+
writeFileSync(
|
441
|
+
'./src/main.js',
|
442
|
+
'var _ = ' + comp(src) + '; console.log(_)'
|
443
|
+
)
|
444
|
+
break
|
445
|
+
case 'dev':
|
446
|
+
default:
|
447
|
+
dev(src, typ)
|
448
|
+
break
|
449
|
+
}`
|
449
450
|
)
|
450
451
|
console.log('Added file index.js in root')
|
451
452
|
console.log(
|